jsonpath: Getting TypeError if one of the nodes in json has name "hash"
Hi @Skarlso!
I have a strange issue, suppose the following json:
j = {height: 5, hash: "some_hash"}.to_json
And the following paths
ht = JsonPath.new "$..height"
hs = JsonPath.new "$..hash"
Then in ruby 2.6.0 condole I see this - height is found and hash gives me TypeError exception:
2.6.0 :008 > ht.on j => [5]
2.6.0 :010 > hs.on j Traceback (most recent call last): 16: from (irb):10 15: from (irb):10:in ‘rescue in irb_binding’ 14: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath.rb:73:in ‘on’ 13: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath.rb:73:in ‘to_a’ 12: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:28:in ‘each’ 11: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:26:in ‘each’ 10: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:39:in ‘each’ 9: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:39:in ‘each’ 8: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:39:in ‘block in each’ 7: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:30:in ‘each’ 6: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:60:in ‘handle_wildecard’ 5: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:60:in ‘each’ 4: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:68:in ‘block in handle_wildecard’ 3: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:22:in ‘each’ 2: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:134:in ‘yield_value’ 1: from /Gems/ruby-2.6.0/gems/jsonpath-1.0.4/lib/jsonpath/enumerable.rb:134:in ‘[]’ TypeError (no implicit conversion of String into Integer)
Can you please have a look at it if time?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24
@clergyman !!!
F*cking ruby.