Declares a JSCalendar object from its property table.
Every object in RFC 8984 is the same shape โ a JSON object with an
@type discriminator and a fixed set of typed properties โ so each
one here is a property table rather than a hand-written parser:
use JSCalendar.Object,
type: "Link",
properties: [
{"href", :href, :string, nil},
{"contentType", :content_type, :string, nil}
]Each entry is {json_name, struct_key, type, default}. The macro
generates the struct, from_map/1 and to_map/1.
Two properties of the generated code worth knowing
Unknown properties survive. Anything the table does not name is
kept in extra and written back untouched. RFC 8984 ยง1.5 requires
this: vendor extensions and later revisions of the spec both arrive
as properties an implementation has never heard of, and a parser
that drops them silently corrupts data it was only asked to read.
Defaults are not written back. A property equal to its RFC default is omitted on encode, because the default is what its absence already means. This keeps output small and makes a round trip idempotent rather than steadily more verbose.