Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
2.3.1
-
None
Description
For example, a response with the following JSON object:
{"list": ["a","b","c"]}
The following code snippet will throw a java.lang.IllegalArgumentException: Invalid offset: 0 (size = 0), because list contains 0 child:
Resource list = response.getValue("list", Resource.class);
ResourceCollection collection = list.getChildren();
The reason is, for an ArrayNode backed Resource, JacksonResource#getInternalAllChildren() only add elements of type ContainerNode to the children. See code snippet below:
JsonNode value; int index = 0; for (Iterator<JsonNode> it = jsonNode.elements(); it.hasNext();) { value = it.next(); if (value.isContainerNode()) { list.add(this.toChildIndexedJacksonResource(value, ++index)); } }
Attachments
Issue Links
- is backported by
-
CRISP-51 [Backport 12.5] Unable to extract JSON array with scalar elements from Resource object
- Closed