Skip to content

Add basic Stream support in JsonNode: valueStream(), propertyStream(), forEachEntry()Β #4863

Closed

Description

@cowtowncoder

(note: part of JSTEP-3 work)

Currently use of Tree Model with Java 8 Streams is bit more complicated than necessary, since there are no java.util.stream.Stream producing methods in JsonNode. But it should be straight-forward at methods as follows:

  1. Stream<JsonNode> JsonNode.valueStream(): for ArrayNode return Stream of all element JsonNodes; for ObjectNode return Stream of all values of child entries; for other nodes empty Stream
  2. Stream<Map.Entry> JsonNode.propertyStream(): for ObjectNode return Stream of all properties (name, value pairs); for other nodes empty Stream
  3. void JsonNode.forEachEntry(BiConsumer<String, JsonNode>): for ObjectNode calls consumer with all entries; for other nodes does nothing.

In future we could also consider some of:

  • "parallel" stream variants (for valueStream(), propertyStream())
  • "spliterator" for value/property streams

But let's start with the simplest cases first.

Activity

  1. self-assigned this
    on Dec 22, 2024
  2. added a commit that references this issue on Dec 23, 2024
    947fd65
  3. added this to the 2.19.0 milestone on Dec 23, 2024
  4. added a commit that references this issue on Dec 23, 2024
    a7cf2f3
  5. changed the title [-]Add basic Stream support in `JsonNode`: `valueStream()`, `entryStream()`, `forEachEntry()`[/-] [+]Add basic Stream support in `JsonNode`: `valueStream()`, `propertyStream()`, `forEachEntry()`[/+] on Dec 28, 2024
  6. cowtowncoder commented on Dec 28, 2024

    @cowtowncoder
    MemberAuthor

    NOTE: renamed entryStream -> propertyStream as per naming guidance of JSTEP-6

  7. added a commit that references this issue on May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2.19Issues planned at 2.19 or later

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions