Skip to content

Add Stream-friendly alternative to JsoneNode.fields(): Set<Map.Entry<String, JsonNode>> properties() #3809

@cowtowncoder

Description

@cowtowncoder

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 consider entries() or properties()?
  • JsonNode.valueStream() -- but could consider just values()?

EDIT: At this point, favoring

  • JsonNode.values() for single-value Stream (Array elements, Map entry values)
  • JsonNode.properties() for Map.Entry<String, JsonNode> valued stream

backed by simple implementations of:

  • ArrayList.stream() (ArrayNode), Map.values().stream() (ObjectNode)
  • Map.entrySet().stream()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions