class Date
def as_json(*)
# => #
Date.json_create(x)
\Method +JSON.create+ deserializes such a hash, returning a \Date object:
# => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
x = Date.today.as_json
require 'json/add/date'
returning a 2-element hash representing +self+:
\Method Date#as_json serializes +self+,
see Marshal[https://docs.ruby-lang.org/en/master/Marshal.html].
to serialize and deserialize a \Date object;
Methods Date#as_json and +Date.json_create+ may be used
def as_json(*) { JSON.create_id => self.class.name, 'y' => year, 'm' => month, 'd' => day, 'sg' => start, } end