I am trying to convert a JSON array to a Java object, but I am having problems understanding how to use GSON.
The JSON array looks like this:
"[
{
"category": "1",
"checks": [
{
"check": "1.1",
"penaltypoints": "1.1",
"keypoint": "1.1"
},
{
"check": "1.2",
"penaltypoints": "1.2",
"keypoint": "1.2"
}
]
},
{
"category": "2",
"checks": [
{
"check": "2.1",
"penaltypoints": "2.1",
"keypoint": "2.1"
},
{
"check": "2.2",
"penaltypoints": "2.2",
"keypoint": "2.2"
}
]
}
]"
My corresponding Java classes are:
class Category {
public String description;
public List<Check> checks;
}
class Check {
public String description;
public float penaltyPoints;
public KeyPoint keypoint;
}
class KeyPoint {
public String description;
}
And this is how I called GSON:
Gson gson = new Gson();
Category categoriesArray[] = gson.fromJson(jsonString, Category[].class);
At the moment it is throwing up the following error:
Expected BEGIN_OBJECT but was STRING at line 1 column 125
I am new to GSON and am having problems understanding how it works. Can anyone please help me understand what I am doing wrong?