Class: MultiJson::Adapters::OkJson

Inherits:
MultiJson::Adapter show all
Includes:
ConvertibleHashKeys
Defined in:
lib/multi_json/adapters/ok_json.rb

Direct Known Subclasses

Nsjsonserialization

Constant Summary collapse

ParseError =
::MultiJson::OkJson::Error

Instance Attribute Summary

Attributes included from Options

#dump_options, #load_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



17
18
19
# File 'lib/multi_json/adapters/ok_json.rb', line 17

def dump(object, options={})
  ::MultiJson::OkJson.valenc(stringify_keys(object))
end

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



11
12
13
14
15
# File 'lib/multi_json/adapters/ok_json.rb', line 11

def load(string, options={})
  string = string.read if string.respond_to?(:read)
  result = ::MultiJson::OkJson.decode("[#{string}]").first
  options[:symbolize_keys] ? symbolize_keys(result) : result
end