【发布时间】:2012-07-20 00:52:56
【问题描述】:
我正在尝试使用 GSON 来解析一些非常简单的 JSON。这是我的代码:
Gson gson = new Gson();
InputStreamReader reader = new InputStreamReader(getJsonData(url));
String key = gson.fromJson(reader, String.class);
这是从 url 返回的 JSON:
{
"access_token": "abcdefgh"
}
我遇到了这个异常:
E/AndroidRuntime(19447): com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2
有什么想法吗?我是 GSON 的新手。
【问题讨论】: