mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-05 18:25:24 +08:00
fix(#887): allow null value strict mode
This commit is contained in:
@@ -527,7 +527,7 @@ public class JSONTokener {
|
||||
}
|
||||
|
||||
private Object getValidNumberOrBooleanFromObject(Object value) {
|
||||
if (value instanceof Number || value instanceof Boolean) {
|
||||
if (value instanceof Number || value instanceof Boolean || value.equals(JSONObject.NULL)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@@ -75,6 +75,13 @@ public class JSONParserConfigurationTest {
|
||||
assertEquals("Value is not surrounded by quotes: badString", je.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowNullInStrictMode() {
|
||||
String expected = "[null]";
|
||||
JSONArray jsonArray = new JSONArray(expected, new JSONParserConfiguration().withStrictMode(true));
|
||||
assertEquals(expected, jsonArray.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleNumericArray() {
|
||||
String expected = "[10]";
|
||||
|
Reference in New Issue
Block a user