>> {}.to_json()=> "{}">> {}.to_json({})TypeError: wrong argument type Hash (expected Data) from (irb):4:in `to_json'' from (irb):4>>This is in Ruby 1.8.6, Rails 2.1.1...but for some reason reloading the source fixes it:>> load ''/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/json/encoders/hash.rb''=> []>> {}.to_json({})=> "{}">>I''m baffled...what''s a "Data" and why should to_json be expecting one? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 8 Sep 2008, at 03:10, Mike Travers wrote:> >>> {}.to_json() > => "{}" >>> {}.to_json({}) > TypeError: wrong argument type Hash (expected Data) > from (irb):4:in `to_json'' > from (irb):4 >>> > > This is in Ruby 1.8.6, Rails 2.1.1...but for some reason reloading the > source fixes it: > >>> load ''/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ >>> active_support/json/encoders/hash.rb'' > => [] >>> {}.to_json({}) > => "{}" >>> > > I''m baffled...what''s a "Data" and why should to_json be expecting one?I vaguely recall seeing something similar if you have one of the other libraries around that provide json conversions - they and ActiveSupport both try and define to_json and things end up in a mess when they both try and do it. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 7, 7:10 pm, Mike Travers <mtrav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> >> {}.to_json() > => "{}" > >> {}.to_json({}) > > TypeError: wrong argument type Hash (expected Data) > from (irb):4:in `to_json'' > from (irb):4 > > > > This is in Ruby 1.8.6, Rails 2.1.1...but for some reason reloading the > source fixes it: > > > > >> load ''/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/json/encoders/hash.rb'' > => [] > >> {}.to_json({}) > => "{}" > > I''m baffled...what''s a "Data" and why should to_json be expecting one?I found that including a line require ''json/pure'' fixes it...apparently the regular json package (which uses a C library) is buggy. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---