Class JSON::Ext::Parser
In: ext/json/ext/generator/generator.c
Parent: Object

This is the JSON parser implemented as a C extension. It can be configured to be used by setting

 JSON.parser = JSON::Ext::Parser

with the method parser= in JSON.

Methods

new   new   parse   parse   quirks_mode?   quirks_mode?   source   source  

Public Class methods

Creates a new JSON::Ext::Parser instance for the string source.

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 19.
  • 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.
  • create_additions: If set to false, the Parser doesn‘t create additions even if a matchin class and create_id was found. This option defaults to true.
  • object_class: Defaults to Hash
  • array_class: Defaults to Array
  • quirks_mode: Enables quirks_mode for parser, that is for example parsing single JSON values instead of documents is possible.

Creates a new JSON::Ext::Parser instance for the string source.

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 19.
  • 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.
  • create_additions: If set to false, the Parser doesn‘t create additions even if a matchin class and create_id was found. This option defaults to true.
  • object_class: Defaults to Hash
  • array_class: Defaults to Array
  • quirks_mode: Enables quirks_mode for parser, that is for example parsing single JSON values instead of documents is possible.

Public Instance methods

Parses the current JSON text source and returns the complete data structure as a result.

Parses the current JSON text source and returns the complete data structure as a result.

Returns a true, if this parser is in quirks_mode, false otherwise.

Returns a true, if this parser is in quirks_mode, false otherwise.

Returns a copy of the current source string, that was used to construct this Parser.

Returns a copy of the current source string, that was used to construct this Parser.

[Validate]