instance method
JSON::Ext::Generator::State#to_hash
to_hash
ext/json/lib/json/ext/generator/state.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ext/json/lib/json/ext/generator/state.rb, line 42
def to_h
result = {
indent: indent,
space: space,
space_before: space_before,
object_nl: object_nl,
array_nl: array_nl,
as_json: as_json,
allow_nan: allow_nan?,
ascii_only: ascii_only?,
max_nesting: max_nesting,
script_safe: script_safe?,
strict: strict?,
depth: depth,
buffer_initial_length: buffer_initial_length,
}
allow_duplicate_key = allow_duplicate_key?
unless allow_duplicate_key.nil?
result[:allow_duplicate_key] = allow_duplicate_key
end
instance_variables.each do |iv|
iv = iv.to_s[1..-1]
result[iv.to_sym] = self[iv]
end
result
end
Alias of #to_h
Returns the configuration instance variables as a hash, that can be passed to the configure method.