I'm using GSON to deserialize my JSON string. It seems to choke when attempting to deserialize a 2D array of objects. Here's the bit:
{ .
..
...
"states": [
{"SPAWNINGPHASE": [{"name": "STATEA", "duration": 4}, {"name": "STATEB", "duration": 4}]},
{"ALIVEPHASE": [{"name": "STATEA", "duration": 5}, {"name": "STATEB", "duration": 4}]}
]
}
The above is a part of a bigger JSON.
I get Expected BEGIN_ARRAY but was BEGIN_OBJECT
I've looked over my JSON, but I don't see where it's incorrect
Group g=gson.fromJson(configFile, Group.class);
That's what I use to start the read. Is this not enough to process the string for the 2D array?
In Group.class I tried both
public State[][] states;
and
public List<List<State>> states;
Everything else seems to deserialize fine.
Do I have to use this (below)?
Type collectionType = new TypeToken<Collection<Integer>>(){}.getType();
Collection<Integer> ints2 = gson.fromJson(json, collectionType);