【发布时间】:2013-12-10 17:10:53
【问题描述】:
我有以下获取json数据的代码:
$.getJSON( "assessments", function( assessments ) {
console.log(assessments);
});
我完美地获取了所有数据,但控制台的输出为
[Object, Object, Object, Object, Object, Object, Object, Object, Object]
我想像这样以 JSON 结构输出值:
[
{
"id": 1,
"person": {
"personId": "person1",
"firstName": "Pactric"
},
"manager": {
"managerId": "manager1"
},
"state": {
"stateId": 1,
"description": null
},
"comments": null
}
]
如何 console.log() 让这个数据完全按照上面的 JSON 结构显示? 我在这个应用程序中使用 $.getJSON 而不是 $.ajax。
【问题讨论】: