Class: JSOG
- Inherits:
-
Object
- Object
- JSOG
- Defined in:
- lib/jsog.rb
Class Method Summary collapse
-
.decode(obj) ⇒ Hash
Convert a (Hash) object graph that was encoded with encode() back to a normal structure with cyclic references.
-
.dump(obj) ⇒ Object
Just like JSON.dump(), but outputs JSOG.
-
.encode(obj) ⇒ Hash
Convert a (Hash) object graph with potential cyclic references into a simpler structure which contains @id and @ref references.
-
.parse(str) ⇒ Object
Just like JSON.parse(), but reads JSOG.
Class Method Details
.decode(obj) ⇒ Hash
Convert a (Hash) object graph that was encoded with encode() back to a normal structure with cyclic references.
21 22 23 |
# File 'lib/jsog.rb', line 21 def decode(obj) return do_decode(obj, {}) end |
.dump(obj) ⇒ Object
Just like JSON.dump(), but outputs JSOG.
31 32 33 |
# File 'lib/jsog.rb', line 31 def dump(obj) return JSON.dump(encode(obj)) end |
.encode(obj) ⇒ Hash
Convert a (Hash) object graph with potential cyclic references into a simpler structure which contains @id and @ref references.
12 13 14 |
# File 'lib/jsog.rb', line 12 def encode(obj) return do_encode(obj, {}) end |
.parse(str) ⇒ Object
Just like JSON.parse(), but reads JSOG. JSON is safe too.
26 27 28 |
# File 'lib/jsog.rb', line 26 def parse(str) return decode(JSON.parse(str)) end |