我想解析这个json
["user": { "ver": "1.5", "name": "Cupcake", "api": "API level 3" },"user": { "ver": "1.6", "name": "Donut", "api": "API level 4" },"user": { "ver": "2.0-2.1", "name": "Eclair", "api": "API level 5-7" }]
用这个代码
private void load() {
if (loading != null && !loading.isDone() && !loading.isCancelled()) {
return;
}
String url="http://www.ribony.com/json.php";
loading=Ion.with(this,url)
.asJsonArray()
.setCallback(new FutureCallback<JsonArray>() {
public void onCompleted(Exception e,JsonArray result) {
if (e != null) {
Log.w("HATA","YUKLEME HATASI");
Log.w("DETAY",e);
}
for (int i=0; i<result.size(); i++) {
Log.w("ADAPTOR","OK");
tweetAdapter.add(result.get(i).getAsJsonObject());
}
}
});
}
当我尝试运行这个应用程序时,应用程序是crashing.Here是我的日志:http://prntscr.com/44jhdf
我该怎么解决呢?
发布于 2014-07-20 15:17:59
错误是您的json,正确的json看起来是:
[
{
"user": {
"ver": "1.5",
"name": "Cupcake",
"api": "API level 3"
}
},
{
"user": {
"ver": "1.6",
"name": "Donut",
"api": "API level 4"
}
},
{
"user": {
"ver": "2.0-2.1",
"name": "Eclair",
"api": "API level 5-7"
}
}
]
若要验证json是否正确,可以使用http://jsoneditoronline.org/index.html
https://stackoverflow.com/questions/24851689
复制相似问题