Class: MultiJson::Adapters::JsonCommon
- Inherits:
-
MultiJson::Adapter
- Object
- MultiJson::Adapter
- MultiJson::Adapters::JsonCommon
- Defined in:
- lib/multi_json/adapters/json_common.rb
Instance Attribute Summary
Attributes included from Options
Instance Method Summary collapse
Methods inherited from MultiJson::Adapter
activate!, defaults, dump, load
Methods included from Options
#default_dump_options, #default_load_options
Instance Method Details
#dump(object, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/multi_json/adapters/json_common.rb', line 19 def dump(object, ={}) .merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if .delete(:pretty) object.to_json() end |
#load(string, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/multi_json/adapters/json_common.rb', line 8 def load(string, ={}) string = string.read if string.respond_to?(:read) if string.respond_to?(:force_encoding) string = string.dup.force_encoding(::Encoding::ASCII_8BIT) end [:symbolize_names] = true if .delete(:symbolize_keys) ::JSON.parse(string, ) end |