This project is archived and is in readonly mode.
[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
-
Jatinder Singh May 4th, 2010 @ 05:40 AM
Disregard my earlier attachment for Rails 2.3. the correct one is attached below.
-
Repository May 4th, 2010 @ 09:24 PM
- State changed from new to committed
(from [bce2c0ce37cbd4abb45ca36362fbb8fae3bbc6b9]) Active Model JSON serializer now supports custom root option
[#4515 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/bce2c0ce37cbd4abb45ca36362fbb8...
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
Attachments
Referenced by
- 4515 [PATCH] Add custom root option to AR JSON Serializer [#4515 state:committed]