Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Add custom root option to AR JSON Serializer

#4515

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.

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

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Jatinder Singh
    Jatinder Singh

    Disregard my earlier attachment for Rails 2.3. the correct one is attached below.

    May 4th, 2010 @ 05:40 AM

  2. Repository
    Repository
    • State changed from new to committed

    May 4th, 2010 @ 09:24 PM