szimek
2008-Dec-02 14:52 UTC
ActiveResource - xml and json format return different results
Hi, I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to JSON and thought that it will work smoothly, but unfortunately it wasn''t the case. XML and JSON formats generate different objects: XML version #<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon Nov 28 11...}> JSON version #<User:0xb746af5c @prefix_options={}, @attributes={"user"=>#<User: 0xb746ac64 @prefix_options={}, @attributes={"created_at"=>Mon Nov 28 11...}> As you can see, when using JSON format, the result is nested. Is there any reason for this? Have it alwyas worked like this or is it a bug? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-02 14:56 UTC
Re: ActiveResource - xml and json format return different results
On 2 Dec 2008, at 14:52, szimek wrote:> > Hi, > > I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to > JSON and thought that it will work smoothly, but unfortunately it > wasn''t the case. > > XML and JSON formats generate different objects: > XML version > #<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon > Nov 28 11...}> > > JSON version > #<User:0xb746af5c @prefix_options={}, @attributes={"user"=>#<User: > 0xb746ac64 @prefix_options={}, @attributes={"created_at"=>Mon Nov 28 > 11...}> >I suspect this is related to the ActiveRecord::Base.include_root_in_json setting Fred> As you can see, when using JSON format, the result is nested. Is there > any reason for this? Have it alwyas worked like this or is it a bug? > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
szimek
2008-Dec-02 20:11 UTC
Re: ActiveResource - xml and json format return different results
On 2 Gru, 15:56, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 2 Dec 2008, at 14:52, szimek wrote: > > > > > > > > > Hi, > > > I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to > > JSON and thought that it will work smoothly, but unfortunately it > > wasn''t the case. > > > XML and JSON formats generate different objects: > > XML version > > #<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon > > Nov 28 11...}> > > > JSON version > > #<User:0xb746af5c @prefix_options={}, @attributes={"user"=>#<User: > > 0xb746ac64 @prefix_options={}, @attributes={"created_at"=>Mon Nov 28 > > 11...}> > > I suspect this is related to the > ActiveRecord::Base.include_root_in_json setting > > Fred > > > As you can see, when using JSON format, the result is nested. Is there > > any reason for this? Have it alwyas worked like this or is it a bug?Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---