Sha256: 6c1a2167a43a911c756588914738496e8a1884f50cc0ee089679be43876e20c9

Contents?: true

Size: 706 Bytes

Versions: 18

Compression:

Stored size: 706 Bytes

Contents

require 'oj' unless defined?(::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

      ParseError = if defined?(::Oj::ParseError)
        ::Oj::ParseError
      else
        SyntaxError
      end

      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]
        ::Oj.dump(object, options)
      end
    end
  end
end

Version data entries

18 entries across 17 versions & 6 rubygems

Version Path
multi_json-1.7.5 lib/multi_json/adapters/oj.rb
multi_json-1.7.4 lib/multi_json/adapters/oj.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
vagrant-shell-0.2.6 vendor/bundle/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
challah-1.0.0.beta3 vendor/bundle/gems/multi_json-1.7.3/lib/multi_json/adapters/oj.rb
challah-1.0.0.beta3 vendor/bundle/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/multi_json-1.7.3/lib/multi_json/adapters/oj.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/multi_json-1.7.3/lib/multi_json/adapters/oj.rb
vagrant-shell-0.2.5 vendor/bundle/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
multi_json-1.7.3 lib/multi_json/adapters/oj.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
challah-1.0.0.beta2 vendor/bundle/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
challah-1.0.0.beta vendor/bundle/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/multi_json-1.7.2/lib/multi_json/adapters/oj.rb
multi_json-1.7.2 lib/multi_json/adapters/oj.rb