Skip to content

Conversation

@netjordanlee
Copy link

Added the pathSegments() method to JsonPath mirroring the only additional feature added in jsonpath-js:0.3.0.

Summary of changes

  • Refactored the Node class and related functions to use an array for the path property instead of a string.
  • Updated the JsonPath class:
    • Modified the paths() method to return stringified paths using convert_path_segment_to_string method.
    • Added a new pathSegments() method to return path segments as arrays (excluding the root).
  • Modified the run function to initialize the root node path as an array.
  • Updated node creation and path extension logic in types/node.php to work with array-based paths.
  • Adjusted related tests in TraverseDescendantTest.php to use array paths.

Copy link
Owner

@loilo loilo left a comment

Choose a reason for hiding this comment

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

Please preserve the pre-existing formatting (tab indentation) in all your edits. If your IDE supports the .editorconfig file which is in the project root, it should do so on its own.
I need this to be done before properly reviewing the PR again as currently, the diff is mostly a big blob of whitespace noise.

@netjordanlee
Copy link
Author

I had an extension in my editor that was unfortunately superseding this and converting the whitespace on save. This should be fixed now.

@loilo
Copy link
Owner

loilo commented Jan 22, 2026

I had to make some adjustments, but couldn't push them back into your PR, so I did those as a separate PR (#5) which includes your changes.

All of this has been published as v0.3.0.

There has been a small breaking change to the paths() method from v0.2.0 which has been documented in the releases.

Thanks for your work on this! 🙂

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