123456789_123456789_123456789_123456789_123456789_

Class: JSON::Ext::Parser

Relationships & Source Files
Inherits: Object
Defined in: ext/json/parser/parser.c,
ext/json/lib/json/ext.rb,
ext/json/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

Class Method Summary

Instance Method Summary

Constructor Details

.new(source, opts = nil) ⇒ Parser

[ GitHub ]

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

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

Class Method Details

.parse Also known as: .parse

Alias for parse.

[ GitHub ]

  
# File 'ext/json/parser/parser.c', line 1367

static VALUE cParser_m_parse(VALUE klass, VALUE Vsource, VALUE opts)
{
    Vsource = convert_encoding(StringValue(Vsource));
    StringValue(Vsource);

    JSON_ParserConfig _config = {0};
    JSON_ParserConfig *config = &_config;
    parser_config_init(config, opts);

    return cParser_parse(config, Vsource);
}

Instance Method Details

#parse

[ GitHub ]

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

def parse
  @config.parse(@source)
end

#source

[ GitHub ]

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

def source
  @source.dup
end