Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
JSON::Ext::Generator::State#to_h
to_h
ext/json/lib/json/ext/generator/state.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/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,
sort_keys: sort_keys,
rfc8785: rfc8785?,
}
allow_duplicate_key = allow_duplicate_key?
unless allow_duplicate_key.nil?
result[:allow_duplicate_key] = allow_duplicate_key
end
result
end
Returns the configuration instance variables as a hash, that can be passed to the configure method.