I have the following sample JSON coming from a server. Duplicate objects are being internally referred to by an id (see the JSON below).
[
{ "id": 1,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"agent@gmail.com"
},
{ "id": 2,
"agent": 1, // here I want the full object and not the Id
"user":"agent1@gmail.com"
}
]
Question: How do I resolve the objects referred to in this fashion given a random JSON object?
(For instance, for the sample JSON above, I will have the below output:)
[
{ "id": 1,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"agent@gmail.com"
},
{ "id": 2,
"agent": {
"id": 1,
"firstName": "gghg",
"lastName": "gh",
"phone": "4543534",
"admin": true
},
"user":"agent1@gmail.com"
}
]