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.
Note that the #load method does not have the serialization semantics of the Marshal/YAML load/dump interface; any embedded Ruby objects will remain in their hash-serialized form. (Global session contents are not trustworthy enough to allow Ruby object serialization.)
Class Method Summary collapse
-
.dump(object) ⇒ Object
Serialize Hash to JSON document.
-
.load(json) ⇒ Object
Unserialize JSON to Hash.
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
61 62 63 |
# File 'lib/global_session/encoding.rb', line 61 def self.dump(object) return ::JSON.dump(object) end |
.load(json) ⇒ Object
Unserialize JSON to Hash.
Parameters
- json(String)
-
A well-formed JSON document
Return
- value(Hash)
-
An unserialized Ruby Hash
50 51 52 |
# File 'lib/global_session/encoding.rb', line 50 def self.load(json) ::JSON.parse(json) end |