js用new Object创建json数据

时间:2014-09-12 10:06:43   收藏:0   阅读:376

var str = ‘‘;
var json = new Object;
var arr =new Array();
 for(var i =0; i<4;i++){
        var jsons = new Object;
        var shopId= i+‘00‘;
        jsons.logisticsType = i+‘0‘;
        jsons.logisticsCost = i+‘0‘;
        jsons.buyerFeedback = i+‘0‘;
        //json += ‘"l‘+shopId+‘":{"logisticsType":‘+logisticsType+‘,"logisticsCost":‘+logisticsCost+‘,"buyFeedback":"‘+buyerFeedback+‘"},‘;
        json[shopId] = jsons;
         str = JSON.stringify([json]);
        // arr.push(str);
        //return str;
        

}

console.log(str) ;    
  

原文:http://www.cnblogs.com/dearxinli/p/3967682.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!