Class: JSON::Ext::Parser

Inherits:
Object
  • Object
show all
Defined in:
ext/json/ext/parser/parser.c,
lib/json/ext.rb,
ext/json/ext/parser/parser.c

Overview

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.

Constant Summary collapse

Config =
Ext::ParserConfig

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, opts = nil) ⇒ Parser

Returns a new instance of Parser.



17
18
19
20
# File 'lib/json/ext.rb', line 17

def initialize(source, opts = nil)
  @source = source
  @config = Config.new(opts)
end

Class Method Details

.parse(Vsource, opts) ⇒ Object

Allow redefinition by extensions Allow redefinition by extensions



1266
1267
1268
# File 'ext/json/ext/parser/parser.c', line 1266

def parse(...)
  new(...).parse
end

Instance Method Details

#parseObject



26
27
28
# File 'lib/json/ext.rb', line 26

def parse
  @config.parse(@source)
end

#sourceObject



22
23
24
# File 'lib/json/ext.rb', line 22

def source
  @source.dup
end