赞
踩
今天用GSON解析数据时出现如下错误:
Android Studio:com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
现找到如下解决办法:
链接:
http://www.oschina.net/question/1248547_121737
方法:
List<Dept> depts = gson.fromJson(gsonString, new TypeToken<List<Dept>>(){}.getType()); 这一句改成 Dept depts = gson.fromJson(gsonString, Dept.class);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。