Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

JSON.parse :symbolize_names => true does not work in every case #70

Closed
isuda opened this Issue · 1 comment

3 participants

@isuda

If you try to parse this json with :symbolize_names, the parser will throw an "interning empty string" exception when trying to convert the empty string to a symbol.

{"":"this is weird","state":"success"}

I'm not sure if there is any good way to "fix" this problem, or if it needs fixing. You could argue that if you could get JSON in that format you shouldn't be using :symbolize_names. I just thought I would report it.

I like using the :symbolize_names option, but it sucks that it will fail in this specific way on valid json. (even if that json is weird...)

@mernen

Yes, I don't think we can really work around that, as mangling the data wouldn't be an acceptable option IMO. Perhaps the best solution is to mention it in the documentation so that people are more aware of this limitation? Same thing applies to nulls: :"\0" will fail on Ruby 1.8, just like JSON.parse('{"foo\u0000": "bar"}', :symbolize_names=>true).

Both restrictions are lifted on Ruby 1.9, by the way. I can't remember any other symbol name restrictions right now.

@flori flori closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.