On 7 Aug., 22:14, Peter De Berdt <[EMAIL PROTECTED]> wrote: > On 07 Aug 2007, at 20:49, dasboe wrote: > > > > > I tried to implement the "Rendering JSON in actions" example from > >http://wiki.rubyonrails.com/rails/pages/HowtoGenerateJSON: > > > @headers["Content-Type"] = "text/plain; charset=utf-8" > > data = { :foo => 'bar', :etc => 'rez' } > > render :text => data.to_json > > > When I try to decode this in javascript with > > > transport.responseText.evalJSON(true); > > > I get this error: > > > SyntaxError: Badly formed JSON string: '{foo: "bar2", etc: "rez"}' > > > javascript seems to expect double quote around the key strings. does > > anyone know how I get this to work? > > http://trac.codefront.net/jsonifier/ > > Best regards > > Peter De Berdt
Thank you very much! That's what i was looking for. So I put ActiveSupport::JSON.unquote_hash_key_identifiers = false in environment.rb, restarted the WEBrick Server and everything worked just fine... Still - What I don't understand is why Rails default behaviour is to produce invalid JSON!? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" 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-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
