Use the jbuilder gem.