JSONObject.NULL

suggest change

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() contract:

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


JSON in Java:
* JSONObject.NULL

Table Of Contents
8 Arrays
10 Maps
11 Strings
25 JAXB
29 Enums
32 Audio
41 Scanner
48 JSON in Java
63 Logging
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
122 JNDI
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
175 Hashtable
177 SortedMap