public static void main(String[] args) throws JSONException { String str = "{field1:123,field2:2,field3:3}"; JSONObject jsonObject = new JSONObject(str); Iterator<String> it = jsonObject.keys(); while(it.hasNext()){ // 获得key String key = it.next(); String value = jsonObject.getString(key); System.out.println("键: "+key+",值:"+value); }
获取json里所有的key-value
最新推荐文章于 2024-07-01 03:09:17 发布