class ActiveSupport::JSON::Encoding::JSONGemEncoder

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/active_support/json/encoding.rbs

class ActiveSupport::JSON::Encoding::JSONGemEncoder
  def jsonify: ((String | Array[String] | Integer) value) -> untyped
end

:nodoc:
:nodoc:

def encode(value)

Encode the given object into a JSON string
def encode(value)
  stringify jsonify value.as_json(options.dup)
end

def initialize(options = nil)

def initialize(options = nil)
  @options = options || {}
end

def jsonify(value)

Experimental RBS support (using type sampling data from the type_fusion project).

def jsonify: ((String | String | String | Integer) value) -> untyped

This signature was generated using 29 samples from 1 application.

calls.
to +object.as_json+, not any of this method's recursive +#as_json+
Note: the +options+ hash passed to +object.to_json+ is only passed

or having to remember to call #as_json recursively.
worry about what base types of objects they are allowed to return
This allows developers to implement #as_json without having to

fully JSON-ready object.
Recursively calls #as_json to the object to recursively build a
and +true+/+false+/+nil+.
primitives like Hash, Array, String, Numeric,
Convert an object into a "JSON-ready" representation composed of
def jsonify(value)
  case value
  when String
    EscapedString.new(value)
  when Numeric, NilClass, TrueClass, FalseClass
    value.as_json
  when Hash
    result = {}
    value.each do |k, v|
      result[jsonify(k)] = jsonify(v)
    end
    result
  when Array
    value.map { |v| jsonify(v) }
  else
    jsonify value.as_json
  end
end

def stringify(jsonified)

Encode a "jsonified" Ruby data structure using the JSON gem
def stringify(jsonified)
  ::JSON.generate(jsonified, quirks_mode: true, max_nesting: false)
end