Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>JSON-lib initially parses and populates a Java Map with the input JSON. Unfortunately, JSON-lib then checks whether every JSON object element name is a JSON <code>null</code>. It's <code>null</code> check is performed in the <code>JSONNull.equals(Object)</code> method. This method returns true for a "null" JSON string, which of course is not actually a JSON <code>null</code> value.</p> <p>I recommend filing a bug with the JSON-lib project for this issue. The implementation of <code>JSONNull.equals(Object)</code> is flawed.</p> <p>Unfortunately, it's not possible to handle this with a custom <code>PropertyNameProcessor</code>.</p> <p>Options available for a more immediate solution include altering the JSON-lib code yourself, or switching libraries.</p> <p>If you can switch libraries, I highly recommend <a href="http://jackson.codehaus.org" rel="nofollow">Jackson</a>. Following is an example of using it to deserialize the example JSON in the original question.</p> <pre><code>/* { "properties" : { "null" : { "value" : false } } } */ String json = "{\"properties\":{\"null\":{\"value\":false}}}"; ObjectMapper mapper = new ObjectMapper(); Map&lt;String, Object&gt; map = mapper.readValue(json, Map.class); System.out.println(map); // output: {properties={null={value=false}}} Map&lt;String, Object&gt; propertiesMap = (Map) map.get("properties"); System.out.println(propertiesMap); // output: {null={value=false}} Map&lt;String, Object&gt; nullMap = (Map) propertiesMap.get("null"); System.out.println(nullMap); // output: {value=false} </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload