14
I wish to use GSON to parse the following json:
[
[
"hello",
1,
[2]
],
[
"world",
3,
[2]
]
]
So, that's 1 array, containing 2 arrays. The 2 inner arrays are themselves arrays, comprised of String, int, array types.
I'm unsure how I can using Java classes to model the array which has 3 different types (String, int, array). I start with:
// String json just contains the aforementioned json string.
ArrayList<ArrayList<XXX>> data = new ArrayList<ArrayList<XXX>>();
Type arrayListType = new TypeToken<ArrayList<ArrayList<XXX>>>(){}.getType();
data = gson.fromJson(json, arrayListType);
But what should be where the 'XXX' are? I think it should be an array, but it should be an array with 3 different data types. So how can I use Java to model this?
Can any help? Thank you.