JSONObject简单测试使用

前端之家收集整理的这篇文章主要介绍了JSONObject简单测试使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


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

原文链接:https://www.f2er.com/json/289229.html

猜你在找的Json相关文章