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

json字符串转jsonObject|| jsonArray

2018-03-26 22:00 411 查看
1.json字符串转jsonArray
JSONArray json = (JSONArray) JSONArray.parse(str);
for (Object obj : json) {
JSONObject jo = (JSONObject)obj;
int projectid= jo.getInteger("projectid");
String projectname= jo.getString("projectname");
System.out.println("projectid---" + projectid+ "---projectname---" + projectname);
}

2.json字符串转成 json对象
JSONObject jsStr = JSONObject.parseObject(str); //将字符串{“id”:1}
  int jsID = Integer.parseInt(jsStr.getString("id"));//获取id的值
String projectNumber = jsStr.getString("projectNumber");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: