On Aug 13, 3:38 am, "w.d."
<wdjin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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>
> Any help will be greatly appreciated
>
> Regards,
>
> w.d.