Module: MultiJson::Engines::JsonCommon

Included in:
JsonGem, JsonPure
Defined in:
lib/json-schema/lib/multi_json/multi_json/engines/json_common.rb

Instance Method Summary collapse

Instance Method Details

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



5
6
7
8
9
10
# File 'lib/json-schema/lib/multi_json/multi_json/engines/json_common.rb', line 5

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

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



12
13
14
# File 'lib/json-schema/lib/multi_json/multi_json/engines/json_common.rb', line 12

def encode(object, options = {})
  object.to_json(process_options(options))
end