Add Stream-friendly alternative to JsoneNode.fields()
: Set<Map.Entry<String, JsonNode>> properties()
· Issue #3809 · FasterXML/jackson-databind (original) (raw)
Currently with Jackson 2.x the only way to traverse entries of ObjectNode
is using fields()
method.
This has the problem that it returns Iterator
(of Map.Entry<String, JsonNode>
) which is awkward to use (with Java 8 and above).
Similarly we can consider adding methods to replace:
- public Iterator iterator();
- public Iterator elements();
for "values" stream.
Naming-wise I am thinking of
JsonNode.entryStream()
-- but could also considerentries()
orproperties()
?JsonNode.valueStream()
-- but could consider justvalues()
?
EDIT: At this point, favoring
JsonNode.values()
for single-value Stream (Array elements, Map entry values)JsonNode.properties()
forMap.Entry<String, JsonNode>
valued stream
backed by simple implementations of:
ArrayList.stream()
(ArrayNode),Map.values().stream()
(ObjectNode)Map.entrySet().stream()