class JSON::Ext::ParserConfig - Documentation for Ruby 4.1
Description: Documentation for the JSON::Ext::ParserConfig class
Keywords: ruby,class,JSON::Ext::ParserConfig

🔍

No recent searches

# class JSON::Ext::ParserConfig

### Public Class Methods

new(opts → {})
Source

    static VALUE cParserConfig_initialize(VALUE self, VALUE opts)
    {
        rb_check_frozen(self);
        GET_PARSER_CONFIG;

        parser_config_init(config, opts);

        RB_OBJ_WRITTEN(self, Qundef, config->decimal_class);

        return self;
    }

Creates a new `JSON::Ext::ParserConfig` instance.

It will be configured by the opts hash. opts can have the following keys:

opts can have the following keys:

- max_nesting: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false|nil|0, it defaults to 100.

- allow_nan: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the `Parser`. This option defaults to false.

- symbolize_names: If set to true, returns symbols for the names (keys) in a `JSON` object. Otherwise strings are returned, which is also the default. It’s not possible to use this option in conjunction with the create_additions option.

- decimal_class: Specifies which class to use instead of the default

      (Float) when parsing decimal numbers. This class must accept a single
      string argument in its constructor.

### Public Instance Methods

parse(source)
Source

    static VALUE cParserConfig_parse(VALUE self, VALUE Vsource)
    {
        GET_PARSER_CONFIG;
        return cParser_parse(config, Vsource);
    }

Parses the current `JSON` text source and returns the complete data structure as a result. It raises `JSON::ParserError` if fail to parse.