restore-lenient-jsonarray initial commit

This commit is contained in:
Sean Leary
2026-06-15 16:43:46 -05:00
parent 33a4698428
commit c073157a61
2 changed files with 22 additions and 4 deletions
@@ -1548,4 +1548,22 @@ public class JSONArrayTest {
nestedArray.add(buildNestedArray(maxDepth - 1));
return nestedArray;
}
@Test
public void TestLenientCommas() {
String str = "[1,,3]";
// Test should fail if default strictMode is true, pass with an extra null entry if false
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration();
if (jsonParserConfiguration.isStrictMode()) {
try {
JSONArray jsonArray = new JSONArray(str);
fail("Expected to throw exception due to invalid string");
} catch (JSONException e) { }
} else {
JSONArray jsonArray = new JSONArray(str);
assertEquals("JSONArray in non-strictMode should contain a null entry",
"[1,null,3]", jsonArray.toString());
}
}
}