Sha256: 6c3097fdc9656b653eb9a07b9eb60f6c9075911385787bd4e545eaa842cc7883

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

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, :create_additions => false)
      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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_json-1.5.1 lib/multi_json/adapters/json_common.rb