Simple path implementation for JSON data extraction #2301
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.
Goal
Enable the next phase of our remote SDK configuration with a simple data extractor.
Design
The new
JsonCollectionPath
class implements the parsing of the path into nodes, and encapsulates the data extraction.Calling
JsonCollectionPath.fromString
splits the string on the dot ('.'
) character and then builds a chain ofPathNode
objects based on each unit of the path:'*'
becomes aWildcardNode
and matches all elements in an array, and all values in an objectPositiveIndex
objects and attempt to match the numbered element of an array. If asked to match against an object (Map
) the index is treated as a property nameNegativeIndex
objects and attempt to match an element from the end of an array (-1
is the last element,-2
is the second-from-last, and so-on). If asked to match against an object (Map
) the index is treated as a property name (verbatim)Map
) and will not match anything else.Testing
New unit tests introduced.