module ViewModel::Controller

def prerender_json_view(json_view, json_references: {})

def prerender_json_view(json_view, json_references: {})
  json_view = wrap_json_view(json_view)
  json_references = wrap_json_view(json_references)
  encode_jbuilder do |json|
    json.data json_view
    if json_references.present?
      json.references do
        json_references.sort.each do |key, value|
          json.set!(key, value)
        end
      end
    end
    yield(json) if block_given?
  end
end