Expose more path fragment operations to public API#1069
Open
jdimeo wants to merge 1 commit intojson-path:masterfrom
Open
Expose more path fragment operations to public API#1069jdimeo wants to merge 1 commit intojson-path:masterfrom
jdimeo wants to merge 1 commit intojson-path:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JsonPath does not create intermediary objects/paths as discussed in #256 , and it shouldn't. However, if you want to do this yourself, very helpful aspects of the JsonPath API are marked as private/protected.
One operation that I was surprised to see was quite difficult was to evaluate a JsonPath at the "immediate parent", something like
root -> tail -> previous.I was able to achieve this using hacky reflection, so this PR opening up the APIs I needed to call with forced reflection access.
PathToken.getPathFragmentseems like the most obvious- the abstract class marks it asprotectedbut all child implementing classes arepublic. Not sure why it's protected.PathToken.getPrevoiusis already available asprev()but it's package-private. If we're willing to exposegetNextwhy notgetPrev?ArrayIndexToken.getIndexesgives a mechanism for that without exposing the entireArrayIndexOperation. This doesn't support slicing, but since it's just a simple getter, it's not promising full support or new functionality.getPathImpl. This is the entry point to all these helpful path fragment/path token APIs from aJsonPathbut I understand how it's confusing withString getPathand might be something you don't want to expose.