遍历所有Map(json)中的键值对

xiaoxiao2021-02-28  90

代码块

获取所有Map(json)中的键值对,例如:

JSONObject json1=JSONObject.fromObject("{'username' : '11111','clientid' : '','password' : '222222'}"); Map<String, Object> map =json1; for (Entry<String, Object> entry : map.entrySet()) { //getKey获取Entry集合中的key、getValue获取value System.out.println(entry.getKey()+"="+entry.getValue()); }
转载请注明原文地址: https://www.6miu.com/read-53708.html

最新回复(0)