Method: JSON::TruffleRuby::Generator::State#initialize

Defined in:
lib/json/truffle_ruby/generator.rb

#initialize(opts = nil) ⇒ State

Instantiates a new State object, configured by opts.

opts can have the following keys:

  • indent: a string used to indent levels (default: ”),

  • space: a string that is put after, a : or , delimiter (default: ”),

  • space_before: a string that is put before a : pair delimiter (default: ”),

  • object_nl: a string that is put at the end of a JSON object (default: ”),

  • array_nl: a string that is put at the end of a JSON array (default: ”),

  • script_safe: true if U+2028, U+2029 and forward slash (/) should be escaped as to make the JSON object safe to interpolate in a script tag (default: false).

  • check_circular: is deprecated now, use the :max_nesting option instead,

  • max_nesting: sets the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum should be checked.

  • allow_nan: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/json/truffle_ruby/generator.rb', line 153

def initialize(opts = nil)
  @indent                = ''
  @space                 = ''
  @space_before          = ''
  @object_nl             = ''
  @array_nl              = ''
  @allow_nan             = false
  @ascii_only            = false
  @as_json               = false
  @depth                 = 0
  @buffer_initial_length = 1024
  @script_safe           = false
  @strict                = false
  @max_nesting           = 100
  configure(opts) if opts
end