Sha256: 9113e1ef0c77beef14fa0e29bd2bbccca89c4d0d8a7ca94b61219641f52412b2

Contents?: true

Size: 622 Bytes

Versions: 58

Compression:

Stored size: 622 Bytes

Contents

module MultiJson
  module Engines
    module JsonCommon

      def decode(string, options={})
        opts = {}
        opts[:symbolize_names] = options[:symbolize_keys]
        string = string.read if string.respond_to?(:read)
        ::JSON.parse(string, opts)
      end

      def encode(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

58 entries across 58 versions & 5 rubygems

Version Path
classiccms-0.3.4 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classiccms-0.3.3 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classiccms-0.3.2 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classiccms-0.3.1 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classiccms-0.3.0 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classiccms-0.2.4.pre vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classicCMS-0.2.3 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classicCMS-0.2.2 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classicCMS-0.2.1 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classicCMS-0.2.0 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
classicCMS-0.1.2 vendor/bundle/gems/multi_json-1.2.0/lib/multi_json/engines/json_common.rb
multi_json-1.2.0 lib/multi_json/engines/json_common.rb