Skip to content

json-path-features #129

Open
Open

Description

@simbo1905

Context

We extracted ~349 JsonPath expression strings from the upstream Jayway JsonPath test suite under .tmp/JsonPath/... and compared them with our current JsonPath test coverage (~48 expressions at the time).

Some Jayway features are legacy (pre-Java-8 era) and should not be copied directly. We still want to track remaining feature gaps so we can decide (with tests) what belongs in this project.

Explicitly Out Of Scope

  • Path-embedded aggregate functions such as $.numbers.avg(), $.sum(), $.min(), $.max(), etc.
    • Modern Java code should use JsonPath.query(...) + Streams.
    • We provide stream helpers in json-java21-jsonpath (see JsonPathStreams) to filter by type and convert values.

Research Candidates (Not Yet Ruled Out)

  1. Regex filters

    • Jayway examples: $[?(@.name =~ /regex/)], $[?(@.name =~ /REGEX/i)]
    • Questions:
      • Do we want =~ at all? If yes, what is the exact regex syntax and escaping rules?
      • Case-insensitive flag handling (/i) and other flags.
  2. Multi-property selection in brackets

    • Examples: $['a', 'b', 'c'], $.store.book[*]['author', 'isbn']
    • Decide semantics: preserve ordering? include missing keys? duplicates?
  3. in operator in filters

    • Example: $[?(@.category in ['fiction', 'reference'])]
    • Decide type rules: strings only? numbers? null handling?
  4. Special key escaping (quotes, commas, backslashes)

    • Examples: $['key,'], $['key\\,'], $['can\\'t delete']
    • Decide escaping rules to match parser/string literal handling.
  5. Keys containing dashes/dots (and dot-notation ambiguity)

    • Examples: $.display-price, $['dot.notation'], $..['display-price']
    • Ensure property printing/reconstruction stays stable.
  6. Deep nested filters (property-paths inside filters)

    • Examples: $[?(@.foo.bar)], $[?(@.parent.child.name)]
    • Decide supported depth and behavior when intermediate nodes are missing.

Suggested Next Steps

  • For each candidate feature:
    • Pick a minimal set of JsonPath expressions from the Jayway string catalog.
    • Add small, explicit tests in json-java21-jsonpath for parsing and evaluation.
    • Decide whether behavior is Goessner-aligned or a deliberate extension.
  • Keep the feature list updated as decisions are made.

Reference

Activity

  1. added 11 commits that reference this issue on Feb 1, 2026
  2. simbo1905 commented on May 19, 2026

    @simbo1905
    OwnerAuthor

    Status at Release 2026.02.05

    What's Implemented (235+ tests across 6 test classes)

    Feature Syntax Example Status
    Root $ ✅
    Property access $.store.book / $['store'] ✅
    Array index [0] / [-1] ✅
    Slices [0:4:2] / [::-1] ✅
    Wildcards $.store.* ✅
    Recursive descent $..price ✅
    Unions [0,1] / ['a','b'] ✅
    Exists filter [?(@.isbn)] ✅
    Comparison filters [?(@.price < 10)] (==, !=, <, >, <=, >=) ✅
    Logical operators [?(@.a && (@.b || !@.c))] ✅
    Limited script [(@.length-1)] ✅
    Stream helpers JsonPathStreams.asDouble(), isNumber(), etc. ✅

    Research Candidates — Decision Status

    Candidate Decision Notes
    Regex filters (=~) ❌ Out of scope Not aligned with Goessner spec; modern Java should use streams
    Multi-property selection ✅ Already done Union syntax $['a','b'] already supported
    in operator ❌ Out of scope Achievable via `
    Special key escaping ⚠️ Partial Basic ['key'] works; complex escaping not yet defined
    Keys with dashes/dots ⚠️ Partial Bracket notation works; dot-notation ambiguity needs tests
    Deep nested filters (@.foo.bar) ✅ Works parseCurrentNodePath supports dotted property paths inside filters

    Out of Scope (confirmed)

    • Path-embedded aggregate functions ($.numbers.avg(), $.sum(), etc.) — use JsonPathStreams + Java Streams instead.

    Suggested Next Steps

    If we want to close this ticket, we should:

    1. Add explicit tests for key escaping and dash/dot key handling to confirm behavior
    2. Decide whether to formally document the supported filter depth for @.foo.bar paths
    3. Close the ticket or convert to a living document

    Test coverage: JsonPathGoessnerTest (98 tests), JsonPathFilterEvaluationTest (19 tests), JsonPathParserTest (118 tests), plus 3 additional test classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions