Hey eggie,

You'd be glad to know that this has been fixed! :) Edge Rails (and
Rails 2.0) will emit valid JSON by default now.

Cheers,
Chu Yeow

On Oct 4, 11:08 am, eggie5 <[EMAIL PROTECTED]> wrote:
> I support this +1
>
> On Sep 27, 7:51 pm, chuyeow <[EMAIL PROTECTED]> wrote:
>
> > Please check out this ticket (which would explain almost 
> > everything):http://dev.rubyonrails.org/ticket/8762
>
> > 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:
>
> > {
> >   "id": 6589,
> >   "code": "SIN",
> >   "name": "Singapore"
>
> > }
>
> > This is not (Rails' JSON encoders do this):
>
> > {
> >   id: 6589,
> >   code: "SIN",
> >   name: "Singapore"
>
> > }
>
> > 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 
> > changesetshttp://dev.rubyonrails.org/changeset/7519andhttp://dev.rubyonrails.or...).
>
> > 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/
> > trunk/activesupport/lib/active_support/json/encoding.rb).
>
> > Cheers,
> > Chu Yeow


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to