I have a JSon File in the structure:
[
{
"name": "north america",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "south america",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "north europe",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "west europe",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "east europe",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "south europe",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "north africa",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "south africa",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "north asia",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "west asia",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "east asia",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "southeast asia",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "south asia",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
},
{
"name": "oceania",
"population": 10,
"wealth": 0,
"education": 0,
"corruption": 0
}
]
To preface, I'm using Gson to parse my Json file. What I want to be able to do is hold the data as a JsonArray
What I've written to do so is:
final Land[] landInfo = new Gson().fromJson(getClass().getResource("../res/LandInfo.json").toExternalForm(), Land[].class)
Which tells me Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
My Land class:
public class Land {
private String name;
private int population;
private int wealth;
private double education;
private double corruption;
public String getName() {
return name;
}
public int getPopulation() {
return population;
}
public void setPopulation(int population) {
this.population = population;
}
public int getWealth() {
return wealth;
}
public void setWealth(int wealth) {
this.wealth = wealth;
}
public double getEducation() {
return education;
}
public void setEducation(double education) {
this.education = education;
}
public double getCorruption() {
return corruption;
}
public void setCorruption(double corruption) {
this.corruption = corruption;
}
}
Why would I get this output from trying to get the array from a well-formatted Json file?