Module: GlobalSession::Encoding::JSON

Defined in:
lib/global_session/encoding.rb

Overview

JSON serializer, used to serialize Hash objects in a form suitable for stuffing into a cookie.

Class Method Summary collapse

Class Method Details

.dump(object) ⇒ Object

Serialize Hash to JSON document.

Parameters

value(Hash)

The hash to be serialized

Return

json(String)

A JSON-serialized representation of value



48
49
50
# File 'lib/global_session/encoding.rb', line 48

def self.dump(object)
  return object.to_json
end

.load(json) ⇒ Object

Unserialize JSON to Hash.

Parameters

json(String)

A well-formed JSON document

Return

value(Hash)

An unserialized Ruby Hash



37
38
39
# File 'lib/global_session/encoding.rb', line 37

def self.load(json)
  ::JSON.load(json)
end