jmoiron / jsonq

simple json field access for golang
MIT License
588 stars 76 forks source link

Confusion About Integer String Keys #7

Open kylebrandt opened 9 years ago

kylebrandt commented 9 years ago

I've read the following multiple times and I still don't get it.

""" For simplicity, integer keys (ie, {"0": "zero"}) are inaccessible by jsonq as integer strings are assumed to be array indexes. """

How can I access the string "Foo" in the following JSON response with jsonq?

{
  "534" : {
    "aliases" : {
      "Foo" : { }
    }
  }
}
jmoiron commented 9 years ago

Basically in order to make everything simpler it's not supported. AFAICT there isn't an actual undecidable thing here, it was just a lot simpler to assume that an integer was an array index. It wouldn't really break anything to fix this, a patch would be welcome.