Class: MultiJson::Adapters::JsonCommon

Inherits:
MultiJson::Adapter show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/multi_json-1.15.0/lib/multi_json/adapters/json_common.rb

Direct Known Subclasses

JsonGem, JsonPure

Instance Method Summary collapse

Methods inherited from MultiJson::Adapter

defaults, dump, load

Methods included from Options

#default_dump_options, #default_load_options, #dump_options, #dump_options=, #load_options, #load_options=

Methods included from Singleton

#duplicable?

Instance Method Details

#dump(object, options = {}) ⇒ Object



17
18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/multi_json-1.15.0/lib/multi_json/adapters/json_common.rb', line 17

def dump(object, options = {})
  options.merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty)
  object.to_json(options)
end

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



8
9
10
11
12
13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/multi_json-1.15.0/lib/multi_json/adapters/json_common.rb', line 8

def load(string, options = {})
  if string.respond_to?(:force_encoding)
    string = string.dup.force_encoding(::Encoding::ASCII_8BIT)
  end

  options[:symbolize_names] = true if options.delete(:symbolize_keys)
  ::JSON.parse(string, options)
end