Open Parth-Rewind opened 1 year ago
Also note that when using bracket indexing for the object we're checking, we get an error:
JsonPath.new("$[?(!@['pull_request'])]").on(json)
Traceback (most recent call last):
16: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:24:in `each'
15: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:26:in `each'
14: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:55:in `handle_wildecard'
13: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:55:in `each'
12: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:63:in `block in handle_wildecard'
11: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:108:in `handle_question_mark'
10: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:108:in `times'
9: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:110:in `block in handle_question_mark'
8: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/enumerable.rb:160:in `process_function_or_literal'
7: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:31:in `parse'
6: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:45:in `construct_expression_map'
5: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:45:in `each_with_index'
4: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:45:in `each'
3: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:49:in `block in construct_expression_map'
2: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:107:in `parse_exp'
1: from /Users/evansalter/.rvm/gems/ruby-2.6.6/gems/jsonpath-1.1.2/lib/jsonpath/parser.rb:107:in `!'
ArgumentError (wrong number of arguments (given 1, expected 0))
[
{
"id": 2,
"updated_at": "2011-04-22T13:33:48Z"
}
]
I've got a PR to fix this incoming.
Sample JSON: Response from Github when getting a list of all issues The response contains two objects, one with a
pull_request
property and the other doesn't have apull_request
property.Bug
The request is to support this scenario
Intent: Get all objects from sample json data that don't have a
pull_request
propertyQuery
π Actual Result:
Expected Result
Result From Jsonpath.com
Intent: Get all objects from sample data with the
pull_request
property in the responseQuery
Result from JsonPath