Sha256: f9a54260f5fe0f5b18e40a3f3546a18d6fec7e5c0f0c6117472ffa82a357c947

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

require 'oj' unless defined?(::Oj)

module MultiJson
  module Adapters
    # Use the Oj library to dump/load.
    class Oj
      ParseError = if defined?(::Oj::ParseError)
        ::Oj::ParseError
      else
        SyntaxError
      end

      ::Oj.default_options = {:mode => :compat}

      def self.load(string, options={}) #:nodoc:
        options.merge!(:symbol_keys => options[:symbolize_keys])
        options[:mode] = :strict
        ::Oj.load(string, options)
      end

      def self.dump(object, options={}) #:nodoc:
        options.merge!(:indent => 2) if options[:pretty]
        ::Oj.dump(object, options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_json-1.5.1 lib/multi_json/adapters/oj.rb