- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.4k
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 JsonNodes 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:
- thisfor- ArrayNode
- new ArrayNode()(empty- ArrayNode) for- MissingNode("missing" node)
- new ArrayNode().add(this)for all other- JsonNodeimplementations
to allow unifying processing of otherwise structurally mismatching JsonNode trees.
Metadata
Metadata
Assignees
Labels
No labels