You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
I don't think we should encourage this kind of code by adding API to it. Wrapping all node types except for arrays in a single-element array is a bit weird.
It seems weird from plain JSON perspective, but as @JooHyukKim pointed it makes more sense for XML handling; or more generally for "single Object as-is, two or more as Array" usage patterns which are pretty common (esp. with scripting languages).
While I personally also dislike such polymorphism (if something allows multiple values I feel it ought to be Array even if it contains just 1 element) I think there's something to be said for supporting actual use cases.
(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:
become different
JsonNode
s structurally: basically equivalent of JSON like so:So to help handling with such case -- or, possibly, modifying such content, we could add new method:
which will return:
this
forArrayNode
new ArrayNode()
(emptyArrayNode
) forMissingNode
("missing" node)new ArrayNode().add(this)
for all otherJsonNode
implementationsto allow unifying processing of otherwise structurally mismatching
JsonNode
trees.The text was updated successfully, but these errors were encountered: