I am calling "render :json => @buildings" from a Buildings
controller.
It''s returning
[{"building":{"value":"114 3rd Ave New
York"}},{"building":
{"value":"114 1st Pl
Brooklyn"}},{"building":{"value":"1140 2nd Ave
New York"}},{"building":{"value":"1143 2nd Ave New
York"}}]
As expected, however, I need the json array to NOT be nested within a
"building" node.
i.e. I need:
[{"value":"114 3rd Ave New York"},
{"value":"114 1st Pl Brooklyn"},
{"value":"1140 2nd Ave New York"},
{"value":"1143 2nd Ave New York"}]
I have tried passing various options to the render call and other
to_json and as_json variations.
How would I do this?
Thanks, Elliott G
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
try ActiveRecord::Base.include_root_in_json = false ok. On Mon, Mar 7, 2011 at 4:22 PM, elliottg <x@simplecircle.net> wrote:> I am calling "render :json => @buildings" from a Buildings > controller. > > It''s returning > [{"building":{"value":"114 3rd Ave New York"}},{"building": > {"value":"114 1st Pl Brooklyn"}},{"building":{"value":"1140 2nd Ave > New York"}},{"building":{"value":"1143 2nd Ave New York"}}] > > As expected, however, I need the json array to NOT be nested within a > "building" node. > > i.e. I need: > [{"value":"114 3rd Ave New York"}, {"value":"114 1st Pl Brooklyn"}, > {"value":"1140 2nd Ave New York"}, {"value":"1143 2nd Ave New York"}] > > I have tried passing various options to the render call and other > to_json and as_json variations. > > How would I do this? > > Thanks, Elliott G > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Perfect! Thanks a ton Eduardo. On Mar 7, 2:28 pm, "Eduardo de O. Hernandes" <eduardod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> try > > ActiveRecord::Base.include_root_in_json = false > > ok. > > > > > > > > On Mon, Mar 7, 2011 at 4:22 PM, elliottg <x...-+PdThUrr9bOXUBVsB0ZYTw@public.gmane.org> wrote: > > I am calling "render :json => @buildings" from a Buildings > > controller. > > > It''s returning > > [{"building":{"value":"114 3rd Ave New York"}},{"building": > > {"value":"114 1st Pl Brooklyn"}},{"building":{"value":"1140 2nd Ave > > New York"}},{"building":{"value":"1143 2nd Ave New York"}}] > > > As expected, however, I need the json array to NOT be nested within a > > "building" node. > > > i.e. I need: > > [{"value":"114 3rd Ave New York"}, {"value":"114 1st Pl Brooklyn"}, > > {"value":"1140 2nd Ave New York"}, {"value":"1143 2nd Ave New York"}] > > > I have tried passing various options to the render call and other > > to_json and as_json variations. > > > How would I do this? > > > Thanks, Elliott G > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.