Hey there (excuse my English)
I've been working on an AngularJS front-end website that consumes a web service which produces JSON with Spring MVC. The Spring MVC uses the JsonIdentityInfo option for serialization, so each object is only written once in the JSON and any subsequent references just use an ID. For example, if two "computer" objects are using the same "component", Spring assigns an ID to the first component and the second component just refers to that ID:
[
{
"@computerID": 1,
"component": {
"@componentID": 2,
"processor": 2,
"ram": "8g",
"harddrive": "wd"
}
},
{
"@computerID": 3,
"component": 2
}
]
What I need now:
[
{
"@computerID": 1,
"owner" : "Mister B",
"component": {
"@componentID": 2,
"processor": 2,
"ram": "8g",
"harddrive": "wd"
}
},
{
"@computerID": 3,
"owner" : "Mister A",
"component": {
"@componentID": 2,
"processor": 2,
"ram": "8g",
"harddrive": "wd"
}
}
]
I have searched extensively for code that can achieve this but haven't found anything.
I am unable to modify the web service to change this behavior. Is it possible to edit the JSON on the client side using JavaScript or jQuery (or another library) to replace references with the actual referenced object? (The data structure is quite complex with three levels of subobjects within objects).
Thank you very much.