java 解析动态的key不定的json 格式

tech2023-11-24  84

1. demo

{ "0": { "name": "医学影像资料", "infoList": [ { "name": "梵蒂冈", "num": 1 } ] }, "1": { "name": "检查报告单", "infoList": [ { "name": "昂", "num": 1 } ] } }

 

2.方法

public static void test1(){ String json = "{'0':{'name':'医学影像资料','infoList':[{'name':'梵蒂冈','num':1}]},'1':{'name':'检查报告单','infoList':[{'name':'昂','num':1}]}}"; JSONObject jsonObject = JSONUtil.parseObj(json); for (Map.Entry<String, Object> entry : jsonObject.entrySet()) { System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); } }

 

最新回复(0)