0
我要分析此JSON與Android
["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());
}
}
});
}
當我嘗試運行這個程序離子解析JSON,應用程序是crashing.Here是我的logcat:http://prntscr.com/44jhdf
我該如何解決?
它是無效的JSON。 '第2行解析錯誤: [「user」:{「ver」:「 -----------^ 期待'}',',',']' – Aniruddha
@Aniruddha Can你給這樣一個例子json?我看不到錯誤在哪裏 –
利用jsonlint.com你會知道錯誤在哪裏 – Aniruddha