Parse JsonArray without key in android

M.Movaffagh

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)
T.J. Crowder

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

获取 JSONArray 的 Key String

来自分类Dev

Android JSONArray循环

来自分类Dev

Volley for Android的JSONArray响应

来自分类Dev

Android中的JSONArray替代

来自分类Dev

Android ArrayAdapter and JSONArray

来自分类Dev

Android ArrayAdapter和JSONArray

来自分类Dev

Android JSONArray到ArrayList

来自分类Dev

Android:JSONArray解析问题

来自分类Dev

JSONArray内的Android JSONArrays

来自分类Dev

Android JSONArray到ArrayList

来自分类Dev

Android:解析2 jsonArray

来自分类Dev

Android解析2 jsonarray

来自分类Dev

JSON Android解析JSONArray

来自分类Dev

Android上的新JSONArray(String [])

来自分类Dev

解析Android Volley JSONArray响应

来自分类Dev

无法在Android中解析JSonArray

来自分类Dev

返回JSONArray时Android异常

来自分类Dev

从Android中的JSONarray删除JSONobject

来自分类Dev

Android 批量插入或忽略 JSONArray

来自分类Dev

jsonobject无法转换为jsonarray嵌套jsonarray android

来自分类Dev

How do I parse a JSONArray in Java with Json.simple?

来自分类Dev

Android ByteArrayOutputStream损坏了HTTP GET JSONArray

来自分类Dev

从JSONArray转换为ArrayList <CustomObject>-Android

来自分类Dev

JsonArray的任务没有价值-Android

来自分类Dev

Java android JsonArray解析器

来自分类Dev

在Android的JSONArray中存储多维数组

来自分类Dev

用于列表视图的JSONArray排序-Android

来自分类Dev

如何在Android中显示JSONArray值

来自分类Dev

如何在android中解析JSONArray NullPointerException