如何将对象转换为标准的json格式的数据

var data = {
  "status" : 1,
  "data" : {
    "commodityDTO" : [{
      "id" : 1,
      "categoryId" : 4,
      "name" : "mike1",
      "stock" : 20,
      "picPath" : "/Upds/Sho/2009/04/20/5534900cb9f9f",
      "status" : 1,
      "commodityId" : 1000501
    }, {
      "id" : 2,
      "categoryId" : 0,
      "name" : "mike2",
      "stock" : 20,
      "picPath" : "/Upds/Shopp/2010/01/20/5534900cb9f9f",
      "status" : 1,
      "commodityId" : 1001801
    }],
    "commoditySize" : 2,
    "commodityTotal" : 0,
    "categoryCount" : 0
  }
}
 $scope.setAPI = function(openDt,page,pageSize){
      var arry = $.map((openDt),function(value,index){
              return [value]
        })
    arry = arry.slice(1)
       var arr = []
       for(i = 0;i<arry.length;i++){
         arr = arry[i]
       }
       arry =  $.map((arr),function(value,index){
              return [value]
        })
        var pagedData = arry[1].slice((page - 1) * pageSize, page * pageSize);
        $scope.oa = pagedData;
     }
     console.log(arry[1])
    原文作者:MichaelDuan
    原文地址: https://segmentfault.com/a/1190000003050395
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞