Removing JSON elements with jackson

后端 未结 6 745
無奈伤痛
無奈伤痛 2020-12-01 18:06

I\'ve a particular JSON Node that corresponds to import org.codehaus.jackson.JsonNode, and not import org.codehaus.jackson.map.JsonNode.

[
    {
        \"g         


        
6条回答
  •  鱼传尺愫
    2020-12-01 18:18

    According to the JSONObject documentation, JSONObject implements Map.remove, which returns the value stored at that key. Use it like

    JSONObject json = new JSONObject();
    json.put("key", "value");
    String str = (String)json.remove("key");
    

提交回复
热议问题