Iterate through JSONObject from root in json simple

后端 未结 3 1771
梦谈多话
梦谈多话 2020-12-13 04:52

I am trying to iterate over a json object using json simple. I have seen answers where you can do a getJSONObject(\"child\") from

{ \"child\":          


        
3条回答
  •  感动是毒
    2020-12-13 04:58

    In Java 8 we can use lambdas

    void handleJSONObject(JSONObject jsonObject) {
    jsonObject.keys().forEachRemaining(key -> {
        Object value = jsonObject.get(key);
        logger.info("Key: {0}\tValue: {1}", key, value);
      }
    }
    

提交回复
热议问题