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.
Add New Comment
Viewing 4 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks