Module: MultiJson::Adapters::Oj

Extended by:
Oj
Included in:
Oj
Defined in:
lib/vendor/multi_json/lib/multi_json/adapters/oj.rb

Overview

Use the Oj library to dump/load.

Constant Summary collapse

DEFAULT_OPTIONS =
{:mode => :compat, :time_format => :ruby}.freeze
ParseError =
if defined?(::Oj::ParseError)
  ::Oj::ParseError
else
  SyntaxError
end

Instance Method Summary collapse

Instance Method Details

#dump(object, options = {}) ⇒ Object

:nodoc:


23
24
25
26
# File 'lib/vendor/multi_json/lib/multi_json/adapters/oj.rb', line 23

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

#load(string, options = {}) ⇒ Object

:nodoc:


17
18
19
20
21
# File 'lib/vendor/multi_json/lib/multi_json/adapters/oj.rb', line 17

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