当前位置:   article > 正文

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was B_android studio com.google.gson.jsonsyntaxexception

android studio com.google.gson.jsonsyntaxexception: java.lang.illegalstateex

今天用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);



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/246367?site
推荐阅读
相关标签
  

闽ICP备14008679号