I'm trying to use GSON to deserialize some Json to a nice, tidy object. Now, I have managed to get the Json to correctly map to some of the more obvious variables. However, while trying to map some of the Json I came across this:
{
"this_number": 1,
"that_number": 12,
"some_string": "String!",
"list_of_objects": {
"342356676784653234535345": {
"random_double": "0.1235667456456",
"magic": "29",
"health": 1,
"price": 7,
"point": {
"x": 2,
"y": 70
}
},
"2345263767467354": {
"random_double": "0.1235667456456",
"magic": "23",
"health": 1,
"price": 9,
"point": {
"x": 0,
"y": 70
}
}
}
}
It was mapping nicely until I came to "list_of_objects"
. I can't for the life of me work out how to implement it. I think the main issue is that they are no longer static class names, they are randomized. Therefore it would be totally impractical (and impossible) to write something like:
class 342356676784653234535345{
double random_double = 0.0;
//etc
}
I've had a look around Stackoverflow, but the answers seem quite complex and many don't quite answer what I'm wanting to know.
I have played around with the plain Object method used here, but I couldn't find any further information on its usage.
I also keep finding references to mapping to generic types, but I don't quite understand what is going on. For example