-
Notifications
You must be signed in to change notification settings - Fork 13
Implement JSONPath #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement JSONPath #8
Conversation
Copy files from https://github.com/markborkum/pacifica-jsonpath@jsonpath2 and merge conflicts.
|
@markborkum Are you ready for me to start making changes? or are you trying to get the pipeline to pass? |
|
@dmlb2000 Yes, please. If you can get it to "test", I'll fix the "lint" warnings/errors. |
|
@markborkum The linting will force module renaming, it's important to get the lint stage fixed first. |
|
@markborkum There is a global pre-commit exclude directive for the |
Signed-off-by: David Brown <dmlb2000@gmail.com>
Flake8 warned that the operator callables were globals. In a previous commit, the operator callables were refactored into method-locals in the operator's constructor. This is sufficient to resolve the flake8 warnings, but introduces a bug: since callables are created per instance, they have different memory locations, and hence, are not compatible with the `Node`-level definition of `__eq__`, which naively compares each `__dict__` of each operand. The fix is to refactor the operator callables into static methods.
Signed-off-by: David Brown <dmlb2000@gmail.com>
Signed-off-by: David Brown <dmlb2000@gmail.com>
markborkum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rollback this change to the grammar. Both operands being JSON literal values is invalid syntax. For a binary operator, the left-hand operand must be a JSONPath and the right-hand operand must be a JSON value.
|
The reason for adding that was when I was looking at other implementations they had some weird expressions. If you look at some of the tests they have in this test... there's a couple of things.
|
In previous implementations of JSONPath, the current value is implicitly cast to array or object if the next node is an array index subscript or object index subscript. This introduces ambiguity: "is the index subscript referring to the current value, or a child value of the current value?" The solution is to use the wildcard "*" to refer to the child values explicitly.
Signed-off-by: David Brown <dmlb2000@gmail.com>
Signed-off-by: David Brown <dmlb2000@gmail.com>
|
@markborkum Can you think of a jsonpath expression where a Or is that one of those things that would need to be called by creating the object in that state? |
|
@dmlb2000 The objects would need to be hand-constructed. Expressions with zero or one operand would be rejected by the parser (e.g., |
|
@markborkum Would there be any utility in keeping those code blocks around where |
|
@markborkum Also, would array slicing like Yeah, seems like other slicing |
|
@dmlb2000 There is no harm in keeping the code as it is. The implementations of the |
|
@markborkum Where's the spec you refer too? I'm having issues with array slice.
|
|
@dmlb2000 The "spec" is for logical conjunction and logical disjunction in general (behavior for zero, one or more operands, etc.). For array slice notation, the requirement for "start" is an artifact of the grammar. A "step" is always required if the second colon is present in the slice. The issue here is whether or not we are aiming for feature parity with the slice notation in an established programming language (e.g., the host language, Python). |
|
@markborkum I'm thinking we should be similar to the host language as they've got a standard and developers will be used to that kind of array slice behavior. |
Aim for feature parity with equivalent in Python programming language
|
@markborkum The We are missing some big blocks in that file and I'm wondering if we are missing a test, Something like |
|
@dmlb2000 If the visitor is called after the parser has constructed the AST, then the majority of the The JSON grammar is used for literal values in operator-based expressions. To cover the JSON grammar, we should add new tests for the equality operator, e.g., where the right-hand operand is |
|
@markborkum agreed, the
|
|
@markborkum Any last thoughts? I'm good. |
|
@dmlb2000 Ship it! |
dmlb2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me
Copy files from https://github.com/markborkum/pacifica-jsonpath@jsonpath2 and merge conflicts.
Description
n\a
Issues Resolved
Fixes #10
Check List