Expected a string but was BEGIN_ARRAY

1,933 views
Skip to first unread message

Onder Arslan

unread,
Feb 4, 2014, 6:44:38 PM2/4/14
to googl...@googlegroups.com

I have json like following picture.

enter image description here

I have created 3 classes for this json.

First one is Main Class which is called KategoriResult

public class KategoriResult{
private String ErrorMessage;   
private String ResultCode;
private List<KategoriItem> Payload;
 ..
 ..
 getter - setter
 ..

Second KategoriItems

public class KategoriItem implements Serializable{
private int RowIdx;
private int Id;
private String Title;
private String Type;
private String WebUrl;
private List<ChildrenItem> Children;
private Boolean VideoItems;
 ..
 ..
 getter - setter
 ..

and ChildrenItems

 public class ChildrenItem implements Serializable{
private int RowIdx;
private int Id;
private String Title;
private String Type;
private String WebUrl;
private Boolean Children;
private Boolean VideoItems;
 ..
 ..
 getter - setter
 ..

I am trying to convert the json above to java object with gson. I am getting following error : E/AndroidRuntime(1510): com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 7729. HOw can I fix this?

Martin Grajcar

unread,
Feb 4, 2014, 7:41:55 PM2/4/14
to googl...@googlegroups.com
Find line 1 column 7729 and you're done. ;)

But really, so far your JSON looks OK, and there's a problem somewhere in the part you didn't show.

Shorten your data, so that the same error happens, just at a position where's easy to find. AFAIK Gson ignores missing data, so delete and delete.. then you'll see an array where a string belongs.


--
You received this message because you are subscribed to the Google Groups "google-gson" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-gson...@googlegroups.com.
To post to this group, send email to googl...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-gson.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages