Module: Sandal::Json

Defined in:
lib/sandal/json.rb

Overview

Contains JSON encode and decode functionality.

Class Method Summary collapse

Class Method Details

.dump(raw) ⇒ String

Encodes a Ruby object as JSON. This version delegates to MultiJson.

Parameters:

  • raw

    The Ruby object to be encoded

Returns:

  • (String)

    The JSON string representation of the object.



19
20
21
# File 'lib/sandal/json.rb', line 19

def self.dump(raw)
  JSON.generate(raw)
end

.load(encoded) ⇒ Object

Decode a JSON string into Ruby. This version delegates to MultiJson.

Parameters:

  • encoded (String)

    The JSON string representation of the object.

Returns:

  • The decoded Ruby object.



11
12
13
# File 'lib/sandal/json.rb', line 11

def self.load(encoded)
  JSON.parse(encoded)
end