Class: MultiJson::Adapters::Oj
- Inherits:
-
MultiJson::Adapter
- Object
- MultiJson::Adapter
- MultiJson::Adapters::Oj
- Defined in:
- lib/multi_json/adapters/oj.rb
Overview
Use the Oj library to dump/load.
Defined Under Namespace
Classes: ParseError
Instance Method Summary collapse
Methods inherited from MultiJson::Adapter
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
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/multi_json/adapters/oj.rb', line 49 def dump(object, = {}) if OJ_V2 [:indent] = 2 if [:pretty] [:indent] = [:indent].to_i if [:indent] elsif OJ_V3 .merge!(PRETTY_STATE_PROTOTYPE.dup) if .delete(:pretty) else raise "Unsupported Oj version: #{::Oj::VERSION}" end ::Oj.dump(object, ) end |
#load(string, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/multi_json/adapters/oj.rb', line 27 def load(string, = {}) [:symbol_keys] = [:symbolize_keys] ::Oj.load(string, ) end |