Take the 2-minute tour ×

I have object nav in my rails application. But the nav obj will have another nav obj.

My question is, how can i output or render json like this that nav have another sub nav and may have unlimited depth? Many thanks!!!

"nav": [
                "id": 1,
                "name": "Home",
                "icon": "home",
                "nav": [{  id: 2,
                           name: "game"
                           icon: 'game'

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

jbuider is the solution for complex json.

Check the great tutorials for complex json (jbuider) -

1) jbuider Asciicast

2) jbuider customized Json

share|improve this answer
add comment

Use tools such as Jbuilder, Rabl, ...

share|improve this answer
add comment

Your Answer


