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

JSONObject简单测试使用

时间:2016-08-24 17:38:55      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:jsonobjectd


String str = "{‘status‘:1,‘message‘:‘制作证书成功‘,‘data‘:{‘userId‘:‘‘,‘buf‘:‘‘,‘bufP7‘:‘‘,‘certDn‘:‘‘,‘certSn‘:‘‘,‘issuerDn‘:‘‘,‘startTime‘:‘‘,‘endTime‘:‘‘}";

JSONObject j = new JSONObject();

HashMap<String, String> map = new HashMap<String, String>();

map.put("map1", "map1");

map.put("map2", "map2");

map.put("map3", "map3");

j.put("files", map);

j.put("test", "test");

j.put("test1", "test1");

System.out.println(j.toString());

String str1 = j.toString();

JSONObject json = JSONObject.fromObject(str1);

System.out.println(json.get("files"));

JSONObject j2 = JSONObject.fromObject(json.get("files"));

System.out.println(j2.get("map1"));

输出结果:


{"files":{"map3":"map3","map2":"map2","map1":"map1"},"test":"test","test1":"test1"}

{"map3":"map3","map2":"map2","map1":"map1"}

map1

JSONObject简单测试使用

标签:jsonobjectd

原文地址:http://yjm199.blog.51cto.com/4408395/1842005

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