summaryrefslogtreecommitdiff
path: root/ext/json/lib/json/ext.rb
blob: 1fbc3fd7d195792b4c22b9b3a31174ffb8a3fa9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'json/common'

module JSON
  # This module holds all the modules/classes that implement JSON's
  # functionality as C extensions.
  module Ext
    begin
      if defined?(RUBY_ENGINE) == 'constant' and RUBY_ENGINE == 'ruby' and RUBY_VERSION =~ /\A1\.9\./
        require 'json/ext/1.9/parser'
        require 'json/ext/1.9/generator'
      elsif !defined?(RUBY_ENGINE) && RUBY_VERSION =~ /\A1\.8\./
        require 'json/ext/1.8/parser'
        require 'json/ext/1.8/generator'
      else
        require 'json/ext/parser'
        require 'json/ext/generator'
      end
    rescue LoadError
      require 'json/ext/parser'
      require 'json/ext/generator'
    end
    $DEBUG and warn "Using Ext extension for JSON."
    JSON.parser = Parser
    JSON.generator = Generator
  end

  JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
end