class Struct

def as_json(*)


# => #
Struct::Customer.json_create(x)

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

# => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
x = Struct::Customer.new.as_json
Customer = Struct.new('Customer', :name, :address, :zip)
require 'json/add/struct'

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

see Marshal[https://docs.ruby-lang.org/en/master/Marshal.html].
to serialize and deserialize a \Struct object;
Methods Struct#as_json and +Struct.json_create+ may be used
def as_json(*)
  klass = self.class.name
  klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
  {
    JSON.create_id => klass,
    'v'            => values,
  }
end