# JSON nesting

**URL:** <https://www.ruby-forum.com/t/json-nesting/137556>\
**Category:** Rails\
**Created:** [May 14, 2008, 6:41am UTC](https://www.ruby-forum.com/t/json-nesting/137556 "2008-05-14T06:41:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arshak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@arshak](https://www.ruby-forum.com/u/arshak)\
**Post date:** [May 14, 2008, 6:41am UTC](https://www.ruby-forum.com/t/json-nesting/137556/1 "2008-05-14T06:41:22Z")

</div>

I’m trying to return JSON from a controller method with a certain type  
of nesting to satisfy the requirements of a javascript UI component:

This is what I want the JSON to look like

{“page”:“1”,“total”:2,“records”:“13”,“rows”:[{“id”:“13”,“cell”:[“13”,“2007-10-06”,“Client  
3”,“1000.00”,“0.00”,“1000.00”,null]},{“id”:“12”,“cell”:[“12”,“2007-10-06”,“Client  
2”,“700.00”,“140.00”,“840.00”,null]}

Here is my code but id is showing up at the same level of page and total  
rather than being inside of rows (and at the same level as cell)

render :json =\> {:page =\> page, :total =\> total\_pages, :records =\>  
records, :rows =\> {:id =\> @account\_activities.id, :cell =\>  
@account\_activities} }.to\_json

Arshak
