Sha256: 53ceed08e19d36c2ec0648cd61b7df10c6c684252617f7a14e91b0ab8afb6d84
Contents?: true
Size: 977 Bytes
Versions: 95
Compression:
Stored size: 977 Bytes
Contents
module MultiJson module Adapters module JsonCommon def load(string, options={}) string = string.read if string.respond_to?(:read) ::JSON.parse("[#{string}]", process_load_options!(options)).first end def dump(object, options={}) object.to_json(process_dump_options!(options)) end protected def process_load_options!(options={}) process_options!({:create_additions => false}, options) do |opts| opts.merge!(:symbolize_names => true) if options.delete(:symbolize_keys) end end def process_dump_options!(options={}) process_options!({}, options) do |opts| opts.merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty) end end def process_options!(default_options, options) return default_options if options.empty? yield default_options default_options.merge!(options) end end end end
Version data entries
95 entries across 93 versions & 7 rubygems