Please check out this ticket (which would explain almost everything):
So basically, Rails to_json methods produces invalid JSON out of the
box as it doesn't quote all hash keys. This is valid JSON:
This is not (Rails' JSON encoders do this):
I'm sure many of us would like to see Rails start producing valid JSON
by default instead of having to change a module attribute. I think
it's absolutely important that Rails outputs valid JSON by default.
Would definitely be imperative prior to the Rails 2.0 release,
especially with the attempt to achieve feature parity between XML and
JSON for encoding, decoding and serialization (see changesets
http://dev.rubyonrails.org/changeset/7519 and http://dev.rubyonrails.org/changeset/7518).
If there's a historical reason for it, can someone shed some light?
Worst case is that Rails 2.0 goes out with a big fat JSON warning
about the invalid JSON by default
Oh and the easiest solution: set
ActiveSupport::JSON.unquote_hash_key_identifiers = false
by default in ActiveSupport::JSON (http://dev.rubyonrails.org/browser/