class JbuilderTemplate

def cache_root!(key=nil, options={})

# json.extra 'This will not work either, the root must be exclusive'

end
json.extract! @person, :name, :age
json.cache_root! @person do

Example:

use this approach to cache deeper inside the hierarchy, like in partials or such. Continue to use #cache! there.
faster, but the drawback is that it only works, as the name hints, at the root. So you cannot
Caches the json structure at the root using a string rather than the hash structure. This is considerably
def cache_root!(key=nil, options={})
  if @context.controller.perform_caching
    ::Kernel.raise "cache_root! can't be used after JSON structures have been defined" if @attributes.present?
    @cached_root = _cache_fragment_for([ :root, key ], options) { yield; target! }
  else
    yield
  end
end