码迷,mamicode.com
首页 > Web开发 > 详细

json处理字符串

时间:2019-01-09 16:11:30      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:mob   obj   amp   end   system   from   com   rom   nbsp   

{
"array": [{
"command": "!&>D(<&!‘&E‘e8n!i&6P&!&()o^4{i_&mi24884675236258&74R5)",
"port": "118030831074908",
"type": "sendmsg"
}],
"code": "00000"
}

JSONObject jsonObject = JSONObject.fromObject(str);
JSONArray jsArr=jsonObject.getJSONArray("array");
JSONObject jsObj= jsArr.getJSONObject(0);
System.out.println(jsObj.get("port"));

 


String str="{\n" +
"\t\"array\": [{\n" +
"\t\t\"command\": \"!&>D(<&!‘&E‘e8n!i&6P&!&()o^4{i_&mi24884675236258&74R5)\",\n" +
"\t\t\"port\": \"118030831074908\",\n" +
"\t\t\"type\": \"sendmsg\"\n" +
"\t}],\n" +
"\t\"code\": \"00000\"\n" +
"}";
JSONObject json= JSONObject.parseObject(str);
System.out.println(json.getString("code"));
JSONArray array=json.getJSONArray("array");
System.out.println(json.getString("array"));
System.out.println(array);
System.out.println(array.getJSONObject(0).getString("port"));

json处理字符串

标签:mob   obj   amp   end   system   from   com   rom   nbsp   

原文地址:https://www.cnblogs.com/foreverstudy/p/10244936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!