What Java data structure can be used to serialize to the following Json which have a set of child objects?
Example:
{
"John": {
"Type": "Person",
"age": 30,
"Sean": {
"Type": "child",
"age": 3
},
"Julian": {
"Type": "child",
"age": 4
}
},
"Paul": {
"Type": "Person",
"age": 64,
"Stella": {
"Type": "child",
"age": 10
},
"James": {
"Type": "child",
"age": 12
}
}
}
Writing John and Paul can be done by: Map<String,Person> but i cannot figure out how to nest the Child without having the 'children' property.
Example:
{
"John": {
"Type": "Person",
"age": 30,
"children": {
"Sean": {
"Type": "child",
"age": 3
},
"Julian": {
"Type": "child",
"age": 4
}
}
}
}
I am not sure it is relevant, but Gson is being used to create the Json file
writefor the children Map, I wasn't able to get it to work as expected and it seems like a very cumbersome solution.