rails/jbuilder — Issue #16: Method to return the Hash representation (for use with as_json)
Author: paulspringett
Created: 2012-01-31 11:07:03+00:00
State: open

It would be really useful to use JBuilder within an `as_json` method definition, as in the following pseudo code:

class Article < ActiveRecord::Base
def as_json
Jbuilder.hash do |json|
json.(@article, :id, :name, :created_at)
json.author @article.author.as_json
end
end
end

that would return a `Hash` object, rather than a JSON string.

This would allow nesting / use with other `as_json` calls etc...

Looking at the [source code](https://github.com/rails/jbuilder/blob/master/lib/jbuilder.rb#L17), it should a relatively straight forward to expose the @attributes?