简体   繁体   中英

json conversion with gson on java

I have json like following picture.

在此处输入图片说明

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?

java: private List ChildrenList;

json: Children : []

May be you should rename "ChildrenList" <-> "Children". What setter name do you use?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM