我一直在努力解决这个问题。希望你们能帮我解决这个问题。
示例API blog posts
申请网址
public void onCallbackCompleted(String data) {
Gson gson = new Gson();
if(data != null) {
HashMap<String, List<Brand>> output = gson.fromJson(
data,
new TypeToken<HashMap<String, List<Brand>>>() {
}.getType()
);
rawData = output.get("posts");
simpleAdapter.clear();
simpleAdapter.addAll(rawData.toArray());
simpleAdapter.notifyDataSetChanged();
}
}
异常
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 2 column 4 path $[0]
at com.google.gson.Gson.fromJson(Gson.java:900)
at com.google.gson.Gson.fromJson(Gson.java:853)
at com.google.gson.Gson.fromJson(Gson.java:802)
at com.varunarl.myapplication.MainActivity.onCallbackCompleted(MainActivity.java:53)
请帮我解决此问题