Sha256: f65f8820dfef8b4eb615bd6436a1a76a672c6dc6bec24168207c1ee187107b14

Contents?: true

Size: 739 Bytes

Versions: 25

Compression:

Stored size: 739 Bytes

Contents

require 'oj'
require 'multi_json/adapter'

module MultiJson
  module Adapters
    # Use the Oj library to dump/load.
    class Oj < Adapter
      defaults :load, :mode => :strict, :symbolize_keys => false
      defaults :dump, :mode => :compat, :time_format => :ruby, :use_to_json => true

      ParseError = defined?(::Oj::ParseError) ? ::Oj::ParseError : SyntaxError

      def load(string, options={})
        options[:symbol_keys] = options.delete(:symbolize_keys)
        ::Oj.load(string, options)
      end

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

Version data entries

25 entries across 18 versions & 10 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapters/oj.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapters/oj.rb
multi_json-1.10.1 lib/multi_json/adapters/oj.rb
multi_json-1.10.0 lib/multi_json/adapters/oj.rb
multi_json-1.9.3 lib/multi_json/adapters/oj.rb