Class: MultiJson::Adapters::Oj

Inherits:
MultiJson::Adapter show all
Defined in:
lib/multi_json/adapters/oj.rb

Overview

Use the Oj library to dump/load.

Constant Summary

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

Instance Method Summary collapse

Methods inherited from MultiJson::Adapter

defaults, dump, load

Methods included from Options

#default_dump_options, #default_load_options, #dump_options, #dump_options=, #load_options, #load_options=

Instance Method Details

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



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

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

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



13
14
15
16
# File 'lib/multi_json/adapters/oj.rb', line 13

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