Skip to content

Commit 5d1c789

Browse files
author
Robert Lichtenberger
committed
Add test for JSONArray from Java collection.
1 parent d1327c2 commit 5d1c789

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/org/json/junit/JSONArrayTest.java

+13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ public void verifyConstructor() {
228228
Util.checkJSONArrayMaps(jaRaw);
229229
Util.checkJSONArrayMaps(jaInt);
230230
}
231+
232+
@Test
233+
public void jsonArrayByListWithNestedNullValue() {
234+
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
235+
Map<String, Object> sub = new HashMap<String, Object>();
236+
sub.put("nullKey", null);
237+
list.add(sub);
238+
JSONParserConfiguration parserConfiguration = new JSONParserConfiguration().withJavaNullAsJsonNull(true);
239+
JSONArray jsonArray = new JSONArray(list, parserConfiguration);
240+
JSONObject subObject = jsonArray.getJSONObject(0);
241+
assertTrue(subObject.has("nullKey"));
242+
assertEquals(JSONObject.NULL, subObject.get("nullKey"));
243+
}
231244

232245
/**
233246
* Tests consecutive calls to putAll with array and collection.

0 commit comments

Comments
 (0)