Class: Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/json/add/core.rb

Overview

Symbol serialization/deserialization

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(o) ⇒ Object

Deserializes JSON string by converting the string value stored in the object to a Symbol



26
27
28
# File 'lib/json/add/core.rb', line 26

def self.json_create(o)
  o['s'].to_sym
end

Instance Method Details

#as_jsonObject

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



13
14
15
16
17
18
# File 'lib/json/add/core.rb', line 13

def as_json(*)
  {
    JSON.create_id => self.class.name,
    's'            => to_s,
  }
end

#to_json(*a) ⇒ Object

Stores class name (Symbol) with String representation of Symbol as a JSON string.



21
22
23
# File 'lib/json/add/core.rb', line 21

def to_json(*a)
  as_json.to_json(*a)
end