joshbuddy / jsonpath

Ruby implementation of http://goessner.net/articles/JsonPath/
MIT License
447 stars 72 forks source link

Not possible to access values of numeric keys #134

Closed mbajur closed 3 years ago

mbajur commented 3 years ago

Hello!

I just stumbled upon an issue that it's not possible to access values of numeric keys. Let's say we have a following json, while trying to access 1 key, nil gets returned:

data = {
  "1": "foo"
}
JsonPath.new("$.1").on(data.to_json)
# => [nil]
Skarlso commented 3 years ago

Hi @mbajur. Thanks for reporting. I found the "bug". I reluctantly call it a bug, because I have no idea why it was there in the first place. :D And all the tests seem to be working even if we don't cast the key to an Integer. So here's to hoping nothing other broke.. :D

mbajur commented 3 years ago

i'm glad you nailed it that easily :) thanks!

Skarlso commented 3 years ago

Released the fix. Cheers!