I’m having some trouble with GSON, mainly deserializing from JSON.
I have the following JSON:
{
"1" : {
"name" : "NAME",
"admins" : {
"1": {
"name2" : "NAME2",
"admins2" : {
"1": { ... },
"2": { ... },
......
"n": { ... }
}
},
"2": { ... },
"3": { ... },
......
"n": { ... }
}
},
"2" : { ... },
"3" : { ... },
......
"n" : { ... }
}
I need to find the Class to represent that json with gson, my problem is the “id” ( represented by the “n” correlatives integers nested)
I am assuming you want a way to store keys which are Integers.
You want a way to use the Json String . Since they are integers, there can be “n” number of keys
and each key will have it values.
One way to do this is to use a HashMap.
The keys are stored in the Map as Integers.
Unlimited number of keys can be used.
Easily iterate through the key value pair.
Easily extendisible to add differernt objects.