您的位置:首页 > 移动开发 > Objective-C

android JSONArray JSONObject 字符串转json数组 遍历json对象

2016-11-29 15:39 585 查看
String json = "{''data'':[{''name'':''Wallace''},{''name'':''Grommit''}]}";
StringBuffer  marketXml = new StringBuffer();

jsonObjSplit = new JSONObject(json );
JSONArray ja = jsonObjSplit.getJSONArray("data'");
for (int i = 0; i < ja.length(); i++) {
JSONObject jo = (JSONObject) ja.get(i);

marketXml.append(jo.get(''name'"));
System.out.println(marketXml.toString());
}
-------------------------------------------------------------------------遍历json 对象

jsonObj = new JSONObject(activeMarketRet);

for (Iterator iter = jsonObj.keys(); iter.hasNext();) { //先遍历整个 people 对象
String key = (String)iter.next();
System.out.println(jsonObj .getString(Key));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: