class Symbol

def self.json_create(o)

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

def as_json(*)


Symbol.json_create(x) # => :foo

\Method +JSON.create+ deserializes such a hash, returning a \Symbol object:

# => {"json_class"=>"Symbol", "s"=>"foo"}
x = :foo.as_json
require 'json/add/symbol'

returning a 2-element hash representing +self+:
\Method Symbol#as_json serializes +self+,

see Marshal[https://docs.ruby-lang.org/en/master/Marshal.html].
to serialize and deserialize a \Symbol object;
Methods Symbol#as_json and +Symbol.json_create+ may be used
def as_json(*)
  {
    JSON.create_id => self.class.name,
    's'            => to_s,
  }
end

def to_json(*a)


# {"json_class":"Symbol","s":"foo"}

Output:

puts :foo.to_json
require 'json/add/symbol'

Returns a JSON string representing +self+:
def to_json(*a)
  as_json.to_json(*a)
end