Module: ActionController::JsonRender

Defined in:
runtime/action_controller/json_render.rb

Constant Summary collapse

JSON_ESCAPES =
{
  "\"" => "\\\"", "\\" => "\\\\", "\b" => "\\b", "\f" => "\\f",
  "\n" => "\\n", "\r" => "\\r", "\t" => "\\t"
}.freeze

Class Method Summary collapse

Class Method Details

.encode(value) ⇒ String

the JSON text behind render json:: as_json first, then a structural walk and hand-written JSON text.

Examples:

ActionController::JsonRender.encode({ "ok" => true })
# => "{\"ok\":true}"

Parameters:

  • value (untyped) —

    the object to serialize

Returns:



25
26
27
# File 'runtime/action_controller/json_render.rb', line 25

def self.encode(value)
  emit_json(jsonify(value))
end