Reputation: 1711
The Json is valid but while parsing via. Gson, it gives error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 439
I've pasted the entire Json here.
The column 439 refers to the last character(quotes) in "formFields":[{"
(5th line in paste bin).
Code to parse:
JSONArray results = jsonObject.getJSONArray("results");
String s = results.toString();
Type token = new TypeToken<List<Form>>(){}.getType();
List<Form> formArrayList1 = new Gson().fromJson(s, token);
Form model has all the elements in each json object in the root json array.
public class Form{
-------
-------
JSONArray formFields;
-------
}
Any help will be appreciated!
Upvotes: 0
Views: 321
Reputation: 2943
Your json start with
{"results":[.... so its essentialy an object that has an array field with key "results"
Try to create a wrapper class that will be something like:
class MyWrapper {
List<Form> results;
}
This should get you going.
Edit 1 (user added the results parsing): Try replacing the field with List and create a simple FormField class with just one field (title for ex) for test purposes and see how it goes. (btw paste the all relevant code parts and the whole model, would be easier for us to spot the error)
Upvotes: 2