I was looking at some examples but I couldn't find anything solving my problem. I guess problem is trivial but I can't what I am doing wrong. I have such looking simple JSON:
{
"value" : 120,
"objects" : [
{
"object_id" : 1,
"description" : "First object",
"flag" : false
},
{
"object_id" : 2,
"description" : "Second object",
"flag" : true
}
]
}
I created a model for it:
GeneralResponse:
public class GeneralResponse {
public int value;
public List<NestedObject> objects;
}
NestedObject:
public class NestedObject {
public int object_id;
public String description;
public boolean flag;
}
And I try to parse it like that:
GeneralResponse response = new Gson().fromJson(myJSONstring, GeneralResponse.class);
And I get an error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 4 column 6 path $.objects[0]