-
Notifications
You must be signed in to change notification settings - Fork 201
Proposal: Matching expressions #7
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
Comments
I am OK with the idea of expressions like these as long as they remain portable and have a clear definition. I'm OK with overloading brackets or using the Comments on your operators:
Of course, there are inconsistent ways to do it, but that kind of sacrifice needs very compelling justification. Do you have particular uses in mind or is this just a discussion because you are interested? |
Thanks for thinking about this! I am impressed that you are 'doing it right' on the lexer / parser, and am glad to hear your feedback on the idea!
My own crude implementation of all this is at https://gist.github.com/gregglind/6066375#file-filter_mapper-py-L30-L49 . In this script, this was mostly about 'match' (and return the whole item), not 'only return subsections' The original impetus for running filtering Hadoop jobs, but a minilang against JSON is compelling. Being able to say "Must match this form AND/OR give me these parts" using the same DSL is very compelling. Having 'filter expressions' removes the annoying Some real examples from my own usage:
|
Embedding all of JSON syntax into this simple language is unfortunate, so you have just about convinced me it is better to do this filtering in a layer on top of this.
I believe that the most productive additions, relative to the amount of unresolved issues, would be type filtering and regexes. This all bears some contemplation. |
Merging with #8 |
This might go beyond the original spec, or might belong in a different project :)
What if path bits allowed a limited set of expressions:
$[0 OP value]
whereOP = [==, >, <, >=, <=, !=, =~]
(=~
-> regex on repr)There are some gross side effects:
value
(The dirtiness and complication of this partly depends on what OP's are allowed.)
This capability exists in http://goessner.net/articles/JsonPath/ . I have also found it useful in other projects.
The text was updated successfully, but these errors were encountered: