0
我有從服務器返回JSON對象的一個陣列(如下),的Android不能轉換到的JSONObject錯誤
["{\"schedule\":{\"type\":\"times\"},\"videos\":{\"abc\":\"def\"}}","{\"schedule\":{\"type\":\"tod_repeat\",\"start\":\"00:09:00\"},\"videos\":{\"mk_320059\":{\"url\":\"http://m.mtvkatsomo.fi/?progId=320059\",\"siteId\":\"mk\"}}}"]
這似乎是有效的JSON按照JSONLint(http://jsonlint.com/)。但是在android系統,當我嘗試將其轉換爲一個對象,我得到一個例外,
org.json.JSONException: Value {"schedule":{"type":"times"},"videos":{"abc":"def"}} at 0 of type java.lang.String cannot be converted to JSONObject
的相關代碼,
if (resp != null) {
try {
JSONArray lists = new JSONArray(resp);
Log.d(CLASS_NAME, "STRING REP:"+lists.getJSONObject(0).toString()); // <-- at this line
} catch (JSONException e) {
e.printStackTrace();
}
}
好像我失去了一些東西在這裏,我似乎無法人物擺脫這裏的問題。任何幫助表示讚賞。
蕩,不能相信我沒趕上。謝謝! –