class Set

def self.json_create(object)

See #as_json.
def self.json_create(object)
  new object['a']
end

def as_json(*)


Set.json_create(x) # => #

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

# => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
x = Set.new(%w/foo bar baz/).as_json
require 'json/add/set'

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

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

def to_json(*args)


{"json_class":"Set","a":["foo","bar","baz"]}

Output:

puts Set.new(%w/foo bar baz/).to_json
require 'json/add/set'

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