JSON Builder for Rails?

How to build JSON formatted data structures like XML's are done with
rxml templates?

I can't use to_json method because I need other formatting than
object's one... probably I should play with strings within html.erb
templates if there isn't any better solution or JSON builder?

it's not exactly like rxml but should do the job: