I have a List that, when serialized as JSON, gives me an array of objects. However, I need the serialized version to be structured as follows:
{
"item3":{
"id":3,
"name":"monkey"
},
"item4":{
"id":4,
"name":"turtle"
}
}
Currently, JSON serialization is structured as follows:
[
{
"id":3,
"name":"monkey"
},
{
"id":4,
"name":"turtle"
}
]
My goal is to be able to refer to an array by element identifier instead of a numerical index (ie arr ["item3"]. Name instead of arr [0] .name).
source
share