If you need to add a property with a null value, you should use the predefined static final JSONObject.NULL and not the standard Java null reference.

JSONObject.NULL is a sentinel value used to explicitly define a property with an empty value.

JSONObject obj = new JSONObject();
obj.put("some", JSONObject.NULL);   //Creates: {"some":null}
System.out.println(obj.get("some"));//prints: null

Note

JSONObject.NULL.equals(null); //returns true

Which is a clear violation of [Java.equals()](<https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)>) contract:

For any non-null reference value x, x.equals(null) should return false