Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
Posted 痛而不觉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gson 解析Json数据时候报错: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $相关的知识,希望对你有一定的参考价值。
转换
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方法*/
上面住哪换的时候报错了,穿的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 $的主要内容,如果未能解决你的问题,请参考以下文章