Parent

Files

Struct

Struct serialization/deserialization

Public Class Methods

json_create(object) click to toggle source

Deserializes JSON string by constructing new Struct object with values v serialized by to_json.

    # File lib/json/add/struct.rb, line 10
10:   def self.json_create(object)
11:     new(*object['v'])
12:   end

Public Instance Methods

as_json(*) click to toggle source

Returns a hash, that will be turned into a JSON object and represent this object.

    # File lib/json/add/struct.rb, line 16
16:   def as_json(*)
17:     klass = self.class.name
18:     klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
19:     {
20:       JSON.create_id => klass,
21:       'v'            => values,
22:     }
23:   end
to_json(*args) click to toggle source

Stores class name (Struct) with Struct values v as a JSON string. Only named structs are supported.

    # File lib/json/add/struct.rb, line 27
27:   def to_json(*args)
28:     as_json.to_json(*args)
29:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.