JSON stringify显示java脚本对象数组

时间:2017-05-30 17:31:02

标签: javascript jquery json stringify

对我来说有点困惑我通过我的ajax调用获得结果我将其转换为我的用户定义的对象脚本并且我将该结果推送到数组中并且我将其转换为JSOn数据,就像这样

function orgNameAndIdListClass(id, name) {
  this.label = name;
  this.value = name;
  this.idValue = id;
}
orgNameAndIdList = [];



$.get("../organizationSourceMapping/listOrg.htm?sourceMasterFilter=",
function(response) {
  if (response.status == "LIST_SUCCESS") {
    var listOrgIdAndName = response.successObject.listOrgIdAndName;
    for (var i = 0; i < listOrgIdAndName.length; i++) {
      var orgNameIds = new orgNameAndIdListClass(listOrgIdAndName[i].id, listOrgIdAndName[i].organizationFullName);
      orgNameAndIdList.push(orgNameIds);
    }
  }, 'json')
.fail(function(response) {
  $('#page-wrapper').mask(
    response.status + "**********" + response.statusText);
}); console.log(JSON.stringify(orgNameAndIdList))

});


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

我的orgNameAndIdList每个对象都显示像

这样的数据
idValue:1
label:"org1"
value:"org1"

0 个答案:

没有答案