解决Expected a string but was BEGIN_ARRAY错误 Gson

解析的json


LiveGetStatus liveGetStatus = gson.fromJson(doGetStr(url), LiveGetStatus.class);

出现Expected a string but was BEGIN_ARRAY错误,意思是预期是个字符串,但是是一个数组。

看一下LiveGetStatus类

解决Expected a string but was BEGIN_ARRAY错误 Gson_第1张图片

由于将output解析成了String类型,导致出错

修改:

解决Expected a string but was BEGIN_ARRAY错误 Gson_第2张图片

问题解决。如果报其他的错误,类似下面的,解决方案都是一样的

Expected BEGIN_ARRAY but was STRING

Expected BEGIN_OBJECT but was BEGIN_ARRAY

你可能感兴趣的:(Java开发)