博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

js用new Object创建json数据

Posted on 2014-09-12 09:10  人生梦想起飞  阅读(2014)  评论(0编辑  收藏  举报

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) ;