mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
fix(#887): allow null value strict mode
This commit is contained in:
parent
ce13ebd5fe
commit
898dd5a39d
@ -527,7 +527,7 @@ public class JSONTokener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Object getValidNumberOrBooleanFromObject(Object value) {
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,13 @@ public class JSONParserConfigurationTest {
|
|||||||
assertEquals("Value is not surrounded by quotes: badString", je.getMessage());
|
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
|
@Test
|
||||||
public void shouldHandleNumericArray() {
|
public void shouldHandleNumericArray() {
|
||||||
String expected = "[10]";
|
String expected = "[10]";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user