Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $

转换

 

Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $_第1张图片



public class DepartmentEnt {



    private String org_id;
    private Object org_pid;
    private String org_name;
    private String org_pic;
    private Object org_desc;
    private int org_order;

/*getandset方法*/
    
}

Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $_第2张图片

上面住哪换的时候报错了,穿的type应该是   list<实体>   

{"isError":false,"message":"获取部门List成功!","data":[{"org_id":"2100001","org_pid":null,"org_name":"开发部","org_pic":"test1","org_desc":null,"org_order":0},{"org_id":"2100002","org_pid":null,"org_name":"运维部","org_pic":"test2","org_desc":null,"org_order":1},{"org_id":"2100003","org_pid":null,"org_name":"测试部","org_pic":"test3","org_desc":null,"org_order":2},{"org_id":"2100004","org_pid":null,"org_name":"滑稽部","org_pic":"test4","org_desc":null,"org_order":3}]}

错误原因  data里是jsonarray  

 

解决办法

Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $_第3张图片

你可能感兴趣的:(Android,Studio那些年遇到的坑)