I'm working on parsing a list of cards using GSon for a game I'm making, but I seemed to have hit a wall. The json I'm trying to parse is:
{
"name": "Core Set 2019",
"code": "M19",
"releaseDate": "2018-07-13",
"border": "black",
"type": "core",
"booster": [
[
"rare",
"mythic rare"
],
"uncommon",
"uncommon",
"uncommon",
"common",
"common",
"common",
"common",
"common",
"common",
"common",
"common",
"common",
"common",
"land",
"marketing"
]
}
The issue arises in the booster section. The error message netbeans gives is
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:Expected a string but was BEGIN_ARRAY at line 9 column 8 path $.M19.booster[0]
The code I have so far is:
public class Set
{
public String name;
public String code;
public String releaseDate;
public String border;
public String type;
public List<String> booster;
public Translation translations;
public List<Card> cards;
}
and in main I have
Gson g = new GsonBuilder().create();
Set sets = g.fromJson(new FileReader(JSONNAME), Set.class);
How do I parse the nameless array in an array objects? The nameless array is not always going to be there and I cant change the json because it's being downloaded from a site I do not have access to.