skyscreamer / JSONassert

Write JSON unit tests in less code. Great for testing REST interfaces.
http://jsonassert.skyscreamer.org
Apache License 2.0
1k stars 197 forks source link

"null" is valid JSON #83

Open gimmi opened 7 years ago

gimmi commented 7 years ago

The following example:

JSONAssert.assertEquals("null", "null", false);

result in this exception:

org.json.JSONException: Unparsable JSON string: null

but null is valid JSON, even at the "root" level according to THIS

gimmi commented 7 years ago

Is project dead?

rehevkor5 commented 3 years ago

An example (partial) stack trace due to this problem happening in Spring controller tests:

org.json.JSONException: Unparsable JSON string: null

    at org.skyscreamer.jsonassert.JSONParser.parseJSON(JSONParser.java:56)
    at org.skyscreamer.jsonassert.JSONCompare.compareJSON(JSONCompare.java:49)
    at org.skyscreamer.jsonassert.JSONCompare.compareJSON(JSONCompare.java:125)
    at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:415)
    at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:394)
    at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:336)
    at org.springframework.test.util.JsonExpectationsHelper.assertJsonEqual(JsonExpectationsHelper.java:61)
    at org.springframework.test.web.servlet.result.ContentResultMatchers.lambda$json$9(ContentResultMatchers.java:217)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:196)
...