# Modifying output from to\_json to exclude table name

**URL:** <https://www.ruby-forum.com/t/modifying-output-from-to-json-to-exclude-table-name/162124>\
**Category:** Rails\
**Created:** [March 6, 2009, 12:01am UTC](https://www.ruby-forum.com/t/modifying-output-from-to-json-to-exclude-table-name/162124 "2009-03-06T00:01:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [March 6, 2009, 12:01am UTC](https://www.ruby-forum.com/t/modifying-output-from-to-json-to-exclude-table-name/162124/1 "2009-03-06T00:01:27Z")

</div>

Folks,

I have a Meal model and Model.find(:all).to\_json returns the following

[{“meal”: {“name”: “Veggies Lasagna”, “id”: 1}}, {“meal”: {“name”:  
“Chicken Rice”, “id”: 2}}, {“meal”: {“name”: “Noodle Rice”, “id”: 3}}]

What I want to do is not have the table name (meal) be part of the  
output json string i.e. what I want it to output is

[ {“name”: “Veggies Lasagna”, “id”: 1}, {“name”: “Chicken Rice”, “id”:  
2}, {“name”: “Noodle Rice”, “id”: 3}]

Any way I can do this? I looked at to\_json input options which seem to  
let you control the columns that are output but apparently not the  
table name.

If you are wondering why I need JSON output in this format, that is  
because I want to consume this output from dojo.data.ItemFileReadStore

Thanks for any pointers/help.

-S

---

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [March 6, 2009, 12:12am UTC](https://www.ruby-forum.com/t/modifying-output-from-to-json-to-exclude-table-name/162124/2 "2009-03-06T00:12:37Z")

</div>

Figured it out.

Have to set ActiveRecord::Base.include\_root\_in\_json = false
