Skip to content

Json path#125

Merged
simbo1905 merged 22 commits intomainfrom
JsonPath
Feb 1, 2026
Merged

Json path#125
simbo1905 merged 22 commits intomainfrom
JsonPath

Conversation

@simbo1905
Copy link
Owner

(Optional) When submitting an PR, please consider using a "deep research" tool to sanity check your proposal. Then before submission, run your draft through a strong model with a prompt such as:

"Please review the AGENTS.md and README.md along with this draft PR and check that it does not have any gaps — why it might be insufficient, incomplete, lacking a concrete example, duplicating prior issues or PRs, or not be aligned with the project goals or non‑goals."

(Optional) Please then attach both the prompt and the model's review to the bottom of this template under "Augmented Intelligence Review".


What changed

  • A summary of the changes in this PR

Why this change is needed

  • Motivation / context

How were these changes tested

  • Test plan / manual testing / automated tests etc.

Checklist

  • Code builds / passes tests
  • New tests added if needed
  • Update to use CODING_STYLE_LLM.md convensions
  • Documentation updated if needed
  • AGENTS.md updated if appropriate

(Optional) Augmented Intelligence Review:
Both prompt and model out, asking a strong model to double-check your submission, from the perspective of a maintainer of this repo

cursoragent and others added 5 commits January 31, 2026 16:09
Implements JsonPath query language for the java.util.json backport based on
Stefan Goessner's specification (https://goessner.net/articles/JsonPath/).

Features:
- Parses JsonPath expressions to AST (sealed interface + records)
- Evaluates AST against JsonValue documents from core library
- No external dependencies (java.base only)
- Java 21 functional style (immutable records, pattern matching)
- Pure TDD development with 76 comprehensive tests

Supported operators:
- Root ($), property access (.name, ['name'])
- Array index ([n], [-1]), slice ([:2], [0:10:2])
- Wildcard ([*], .*), recursive descent (..)
- Union ([0,1], ['a','b'])
- Filter expressions ([?(@.isbn)], [?(@.price<10)])
- Script expressions ([(@.length-1)])

All examples from Goessner article implemented as tests.

To verify:
  mvn test -pl json-java21-jsonpath -Djava.util.logging.ConsoleHandler.level=INFO

Co-authored-by: simbo1905 <simbo1905@60hertz.com>
Adds alternative API style for JsonPath queries:
- JsonPath.parse(expr) returns a compiled JsonPath
- .select(json) evaluates against a document
- Compiled paths are reusable across multiple documents
- Retains original JsonPath.query(expr, json) as convenience method

Tests verify:
- parse(...).select(...) returns same results as query(...)
- Compiled paths can be reused on different documents
- expression() accessor returns original path string

To verify: mvn test -pl json-java21-jsonpath

Co-authored-by: simbo1905 <simbo1905@60hertz.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @simbo1905, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new, self-contained module that provides a robust JsonPath query engine. It allows users to parse and evaluate JsonPath expressions against JSON documents, facilitating advanced data extraction and manipulation. The design leverages modern Java 21 features for a clean and efficient implementation, ensuring it integrates seamlessly with the existing java.util.json backport.

Highlights

  • New Module Introduction: A new module, json-java21-jsonpath, has been added to the project, dedicated to providing JsonPath functionality.
  • JsonPath Query Engine: This module implements a comprehensive JsonPath query engine, enabling efficient querying and filtering of JSON documents using JsonPath expressions, tailored for the java.util.json Java 21 backport.
  • Abstract Syntax Tree (AST) Implementation: The JsonPath expressions are parsed into an Abstract Syntax Tree (AST) using Java 21's sealed interfaces and records, ensuring a robust and type-safe representation of the query structure.
  • Extensive Operator Support: The implementation supports a wide array of JsonPath operators, including property access, array indexing, slicing, wildcards, recursive descent, filter expressions (existence and comparison), union operators, and limited script expressions.
  • Zero External Dependencies: Adhering to a core design principle, the JsonPath module operates solely on java.base, avoiding any external library dependencies.
  • Comprehensive Testing: The module includes thorough unit tests for its AST and parser components, alongside integration tests based on Stefan Goessner's original JSONPath specification examples, ensuring correctness and compliance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3eadf514f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new json-java21-jsonpath module, which provides a JsonPath query engine. This is a significant and valuable addition. The code is generally well-structured, using modern Java features like records and sealed interfaces for the AST, and includes a good set of tests based on the Goessner specification.

However, my review has identified several issues that should be addressed:

  • There are a few significant bugs in the implementation, particularly in the handling of array slicing with negative steps and the parsing of the current node (@) in filter expressions.
  • The parser is missing support for logical operators (&&, ||, !) in filters, which is a key part of the JsonPath specification and is incorrectly documented as being implemented.
  • There are some discrepancies between the documentation (ARCHITECTURE.md, AGENTS.md) and the implementation, such as a missing convenience method.
  • Some of the test code is unconventional (using main methods) and contains bugs.

I've provided detailed comments and suggestions for each of these points. Addressing them will greatly improve the correctness and robustness of this new module.

Promote json-java21-jsonpath docs to README.md and keep it focused on public usage (Goessner spec + basic examples). Update human READMEs to use ./mvnw (with -am when selecting modules) and add a top-level JsonPath pointer.\n\nVerify: ./mvnw test -pl json-java21-jsonpath -am -Djava.util.logging.ConsoleHandler.level=INFO
Extend filter parsing to support !, &&, || (with parentheses) and treat bare @ as the current node. Add targeted parser/integration tests plus JsonPathParseException formatting assertions.\n\nVerify: ./mvnw -pl json-java21-jsonpath -am clean test -Djava.util.logging.ConsoleHandler.level=INFO
…false

Corrected !@.prop usage: it means 'property does not exist'. To check for a false boolean value, explicit comparison @.prop == false is required. Updated testComplexNestedLogic to reflect this.
Removed stored path string to save memory. Implemented toString() to reconstruct the path from the AST. Updated usage and tests.
Add JsonPathStreams predicates/converters (strict and OrNull), document stream-based aggregation in json-java21-jsonpath/README.md, and bump AssertJ minimum to 3.27.7 in parent pom.

How to test: ./mvnw test -pl json-java21-jsonpath -am -Djava.util.logging.ConsoleHandler.level=INFO
@simbo1905 simbo1905 merged commit 4e125de into main Feb 1, 2026
4 checks passed
@simbo1905 simbo1905 deleted the JsonPath branch February 1, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants