class OpenStruct

def as_json(*)


# => #
OpenStruct.json_create(x)

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

# => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
require 'json/add/ostruct'

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

see Marshal[https://docs.ruby-lang.org/en/master/Marshal.html].
to serialize and deserialize a \OpenStruct object;
Methods OpenStruct#as_json and +OpenStruct.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,
    't'            => table,
  }
end