Come si imposta un valore su null con org.json.JSONObject in java? Posso certamente leggere se un valore è nullo utilizzando isNull - ma sembra che quando ho messo nulla, semplicemente mi ignora:Come si imposta un valore su null con org.json.JSONObject in java?
JSONObject o = new JSONObject();
o.put("key",null);
o.isNull("key"); // returns true, buuuut...
o.has("key"); // returns false
o.isNull("somethingIHaventSetAtAll"); // also returns true, unfortunately
Se si inserisce il valore null, viene rimossa la chiave: http://www.json.org/javadoc/org/json/JSONObject.html#put(java.lang.String,%20java.lang.Object) –