首页 > 代码库 > js用new Object创建json数据

js用new Object创建json数据

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

js用new Object创建json数据