Closed
Description
(note: part of https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-3 changes)
(inspired by FasterXML/jackson-dataformat-xml#695)
With some JSON structures (as well as other formats, most notably XML), there is sometimes need to process/express things such that single-values that are not express as (JSON) Arrays would be handled same as 1-element arrays. Example shown with XML is that following documents:
<list>
<element>
<a>value 1a</a>
<b>value 1b</b>
</element>
<element>
<a>value 2a</a>
<b>value 2b</b>
</element>
</list>
<list>
<element>
<a>value a</a>
<b>value b</b>
</element>
</list>
become different JsonNode
s structurally: basically equivalent of JSON like so:
{ "list":
"element": [
{ ... },
{ .... }
]
}
{ "list":
"element": {
"a": "value a",
"b": "value b"
}
}
So to help handling with such case -- or, possibly, modifying such content, we could add new method:
ArrayNode asArray();
which will return:
this
forArrayNode
new ArrayNode()
(emptyArrayNode
) forMissingNode
("missing" node)new ArrayNode().add(this)
for all otherJsonNode
implementations
to allow unifying processing of otherwise structurally mismatching JsonNode
trees.
Metadata
Metadata
Assignees
Labels
No labels