Sha256: 76013d9f495aa70d91e6ff1ba17134b2e3e7f575d0fdc59ae7707750e56d53a5

Contents?: true

Size: 678 Bytes

Versions: 9

Compression:

Stored size: 678 Bytes

Contents

# encoding: UTF-8
require 'yajl' unless defined?(Yajl::Parser)

module JSON
  class JSONError < StandardError; end unless defined?(JSON::JSONError)
  class ParserError < JSONError; end unless defined?(JSON::ParserError)
  
  def self.default_options
    @default_options ||= {:symbolize_keys => false}
  end
   
  def self.parse(str, opts=JSON.default_options)
    begin
      Yajl::Parser.parse(str, opts)
    rescue Yajl::ParseError => e
      raise JSON::ParserError, e.message
    end
  end
  
  def self.load(input, *args)
    begin
      Yajl::Parser.parse(input, default_options)
    rescue Yajl::ParseError => e
      raise JSON::ParserError, e.message
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
yajl-ruby-0.7.1 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.7.0 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.9 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.8 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.7 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.6 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.5 lib/yajl/json_gem/parsing.rb
yajl-ruby-0.6.4 lib/yajl/json_gem/parsing.rb
filipegiusti-yajl-ruby-0.6.4 lib/yajl/json_gem/parsing.rb