JSON output format

Hi Everyone,

I am a Rails newbie. I got a minor question about the JSON format
produced by to_json method.

currently my code @events.to_json (:only =>
[:id , :title, :start, :end]) will produce the output :

[{"event": {"title": "Dissect", "id": 996332877, "end":
"2009-07-27T17:46:10Z", "start": "2009-07-27T15:46:10Z"}}, {"event":
{"title": "Operation", "id": 953125641, "end": "2009-07-27T14:46:10Z",
"start": "2009-07-27T12:46:10Z"}}]

but I want the format of the JSON output like

[{"title": "Dissect", "id": 996332877, "end": "2009-07-27T17:46:10Z",
"start": "2009-07-27T15:46:10Z"},{"title": "Operation", "id":
953125641, "end": "2009-07-27T14:46:10Z", "start":
"2009-07-27T12:46:10Z"}]

how can I remove the unnecessary "event" atttribute?

Any help will be greatly appreciated

Regards,

w.d.

Hi Everyone,

I am a Rails newbie. I got a minor question about the JSON format
produced by to_json method.

currently my code @events.to_json (:only =>
[:id , :title, :start, :end]) will produce the output :

[{"event": {"title": "Dissect", "id": 996332877, "end":
"2009-07-27T17:46:10Z", "start": "2009-07-27T15:46:10Z"}}, {"event":
{"title": "Operation", "id": 953125641, "end": "2009-07-27T14:46:10Z",
"start": "2009-07-27T12:46:10Z"}}]

but I want the format of the JSON output like

[{"title": "Dissect", "id": 996332877, "end": "2009-07-27T17:46:10Z",
"start": "2009-07-27T15:46:10Z"},{"title": "Operation", "id":
953125641, "end": "2009-07-27T14:46:10Z", "start":
"2009-07-27T12:46:10Z"}]

how can I remove the unnecessary "event" atttribute?

If you look in the new_rails_defaults.yml file there is a setting that
controls this.

Fred