JsonObject相关操作

一:String转JsonObject:

  JSONObject jSONObject = JSONObject.parseObject(string);

二:获取JsonObject中的value值:

System.out.println("111111111"+jSONObject.getJSONObject("Result").getJSONObject("Result").get("FLinkMan"));

三:JsonObject转ArrayList,遍历ArrayList集合获取key,value值:

  思路:JsonObject先转String,在由String转ArrayList

JSONObject customer = (JSONObject) data.get("CustomerID");
String s = JSONObject.toJSONString(customer.get("Name"));
ArrayList<JSONObject> listName = (ArrayList<JSONObject>) JSONObject.parseArray(s,JSONObject.class);
for (Map entity : listName) {
if(entity.get("Key").equals(2052)) {
dataMap.put("customerName", entity.get("Value"));
}
}

 



posted @ 2023-05-12 16:05  皮卡!皮卡丘  阅读(50)  评论(0编辑  收藏  举报