我有以下來自服務器的示例JSON。重複的對象在內部被id引用(參見下面的JSON)。在JSON中解析引用:Javascript/JSON
[
{ "id": 1,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"[email protected]"
},
{ "id": 2,
"agent": 1, // here I want the full object and not the Id
"user":"[email protected]"
}
]
問: 如何解決中給出隨機JSON對象這種方式引用的對象?
(例如,對於上面的示例JSON,我將具有以下輸出:)
[
{ "id": 1,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"[email protected]"
},
{ "id": 2,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"[email protected]"
}
]
所以你想從服務器得到它後修改JSON或你想在接收到接收JSON在您需要的形式? –
必須從服務器得到它後修改json – kukkuz