Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
JSON::Ext::Parser.new
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
{
GET_PARSER_INIT;
rb_check_arity(argc, 1, 2);
parser_init(json, argv[0], argc == 2 ? argv[1] : Qnil);
return self;
}
Creates a new JSON::Ext::Parser instance for the string source.
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
JSONobject. Otherwise strings are returned, which is also the default. It’s not possible to use this option in conjunction with the create_additions option. -
create_additions: If set to false, the
Parserdoesn’t create additions even if a matching class and create_id was found. This option defaults to false. -
object_class: Defaults to
Hash. If another type is provided, it will be used instead ofHashto representJSONobjects. The type must respond tonewwithout arguments, and return an object that respond to[]=. -
array_class: Defaults to
ArrayIf another type is provided, it will be used instead ofHashto representJSONarrays. The type must respond tonewwithout arguments, and return an object that respond to +<<+. -
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.