This project is archived and is in readonly mode.

#4515 ✓committed
Jatinder Singh

[PATCH] Add custom root option to AR JSON Serializer

Reported by Jatinder Singh | May 1st, 2010 @ 06:39 AM

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

But not following:
user.to_json(:root => "app_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 attached a patch for master and 2.3.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages