Hi,

In short: I can do following:
user.to_xml(:root => "xml_user" )

But not following:
user.to_json(:root => "json_user")

JSON serializer for AR doesn't allow us to specify "root" option unlike XML
serializer. JSON serializer always uses model name as the root if class
attribute include_root_in_json is set to true.

I've added a patch which allows JSON serializer to accepts custom root
option.

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4515-patch-add-custom-root-option-to-ar-json-serializer
Let me know what you think about the patch.


Thanks,
Jatinder
http://twitter.com/rubymerchant
http://blog.jatinder.me

-- 
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 rubyonrails-c...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to