加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSONObject简单测试使用

发布时间:2020-12-16 18:55:14 所属栏目:百科 来源:网络整理
导读:String str = "{'status':1,'message':'制作证书成功','data':{'userId':'','buf':'','bufP7':'','certDn':'','certSn':'','issuerDn':'','startTime':'','endTime':''}"; JSONObject j = new JSONObject(); HashMapString,String map = new HashMapString,S


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","map1":"map1"}

map1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读