Class: MultiJson::Engines::JsonGem

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_json/engines/json_gem.rb

Overview

Use the JSON gem to encode/decode.

Constant Summary collapse

ParseError =
::JSON::ParserError

Class Method Summary collapse

Class Method Details

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

:nodoc:


9
10
11
12
13
14
# File 'lib/multi_json/engines/json_gem.rb', line 9

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

.encode(object) ⇒ Object

:nodoc:


16
17
18
# File 'lib/multi_json/engines/json_gem.rb', line 16

def self.encode(object) #:nodoc:
  object.to_json
end