Jack Nagel 997f9d0075 Update multi_json to 1.5.0
This contains updates to the OkJson library that allow objects to define
to_json for serialization, and this will be used in the upcoming options
and deps work.
2013-01-17 21:39:43 -06:00

26 lines
606 B
Ruby

module MultiJson
module Adapters
module JsonCommon
def load(string, options={})
string = string.read if string.respond_to?(:read)
::JSON.parse(string, :symbolize_names => options[:symbolize_keys], :quirks_mode => true)
end
def dump(object, options={})
object.to_json(process_options(options))
end
protected
def process_options(options={})
return options if options.empty?
opts = {}
opts.merge!(JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty)
opts.merge!(options)
end
end
end
end