Another serialization topic, reduced scope
Tobias Pankrath
tobias+dlang at pankrath.net
Sun Dec 8 21:19:26 UTC 2019
On Saturday, 7 December 2019 at 18:53:51 UTC, Jesse Phillips
wrote:
> @optional
If we look at e.g. json-schema.org or openapis.org they seem to
have optional by default. So we should at least consider this as
well, e.g.
1. have optional by default and introduce @required
2. make it configurable on the containing struct / class
enum IfMissing {
setDefault,
keep
}
@missing(IfMissing.SetDefault)
struct S
{
// all fields by default optional due to @missing
@required
int x;
int a = 4; // set to 0 if not provided during deserialization
}
3. something else ..
More information about the Digitalmars-d
mailing list