Gson解析错误预期BEGIN_ARRAY但是STRING

时间:2015-06-22 04:50:44

标签: java android gson

我遇到了一个问题,但我不知道如何解决。请帮帮我,谢谢! http://i.stack.imgur.com/Uu0me.png 当:

new Gson().fromJson(server_response,Model.class);

Gson错误:

    Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 2621

2 个答案:

答案 0 :(得分:1)

你可以像这样简单地做点什么。

nmap-6.49BETA2-1.i386.rpm
                      ^^^ package format for RedHat not for Debian
                 ^^^^ wrong architecture, the Rasberry pi is arm6 or arm7l

答案 1 :(得分:0)

第1步:将您的回复转换为JSONObject

第2步:picurl JSONArray传递给Gson

Type type = type = new TypeToken<List<Model>>() {}.getType();
Gson objGson = new Gson();
JSONObject response = new JSONObject(responseString);
List<Model> result = objGson.fromJson(response .getJSONArray("picurl").toString(), type);