i have a json response but is this standard format?
[{"code":"123","rate":"0.1","title":"sss","subtitle":"mmm"},{"code":"456","rate":"0.1","title":"bbb","subtitle":"uuu"}]
and how can i pars it in android?
new JSONObject(result.toString())
throw below exception!
06-07 11:45:54.943: W/System.err(10310): at org.json.JSON.typeMismatch(JSON.java:111)
06-07 11:45:54.943: W/System.err(10310): at org.json.JSONObject.<init>(JSONObject.java:158)
06-07 11:45:54.943: W/System.err(10310): at org.json.JSONObject.<init>(JSONObject.java:171)
i have a json response but is this standard format?
It would be without the <
at the beginning and the >
at the end. So:
new JSONObject(result.toString().substring(1, result.length() - 2));
or more likely:
new JSONArray(result.toString().substring(1, result.length() - 2));
since the top level of it is an array.
Since you've removed the <
and >
you had originally:
Since the top level of it is an array, you probably want JSONArray
, not JSONObject
:
new JSONArray(result.toString());
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句