Add custom root option to AR JSON Serializer

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