Valid JSON from Rails
By default Ruby on Rails emits invalid JSON when you use the to_json method. Most of the libraries Rails devs are using to parse JSON, e.g. jQuery or Prototype, work fine with the “invalid” JSON but the JSON Ruby library doesn’t. It requires valid JSON.
Thankfully it is pretty easy to tell Rails to emit valid JSON. Just set ActiveSupport::JSON.unquote_hash_key_identifiers = false in your environment.rb.
September 28th, 2007 at 4:16 pm
Please help add your voice to help get Rails emit valid JSON by default here: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/665949172ad37da0 and here: http://dev.rubyonrails.org/ticket/8762 :)
September 28th, 2007 at 4:16 pm
Please help add your voice to help get Rails emit valid JSON by default here: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/665949172ad37da0 and here: http://dev.rubyonrails.org/ticket/8762 :)
September 28th, 2007 at 4:20 pm
Please help add your voice to get Rails emit valid JSON by default here: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/665949172ad37da0 :)
September 28th, 2007 at 4:21 pm
Ugh sorry for the duplicate submissions, there was an error earlier submitting my comment so I re-entered it :/