Parsing JSON with Unicode in Ruby and Rails
I'm playing with some RESTful web services with a rails app as the client. The service returns JSON.
Cool.
As defined in the spec, JSON strings may contain Unicode characters escaped as '\u four-hex-digits'.
Let's say you had a JSON result with xml, like
{"value":"<xml/>"}
.The service might return
{"value":"\u003cxml/\u003e"}
.That's fine, except the default JSON parser in rails--ActiveSupport::JSON--doesn't (yet?) support unescaping the Unicode characters.
Boo!
A blog post pointed me to the stand-alone JSON rails gem.
That solved my problem.
Happy hacking, my friends.