enum E { @serdeKeys("A", "alpha") a, @serdeKeys("B", "beta") b, c, } auto e = E.c; assert(serdeParseEnum("A", e)); assert(e == E.a); assert(serdeParseEnum("alpha", e)); assert(e == E.a); assert(serdeParseEnum("beta", e)); assert(e == E.b); assert("B".serdeParseEnum!E == E.b); assert("c".serdeParseEnum!E == E.c); assert(!serdeParseEnum("C", e)); assert(!serdeParseEnum("Alpha", e));
Case insensitive
@serdeIgnoreCase // supported for the whole type enum E { @serdeKeys("A", "alpha") a, @serdeKeys("B", "beta") b, c, } auto e = E.c; assert(serdeParseEnum("a", e)); assert(e == E.a); assert(serdeParseEnum("alpha", e)); assert(e == E.a); assert(serdeParseEnum("BETA", e)); assert(e == E.b); assert(serdeParseEnum("b", e)); assert(e == E.b); assert(serdeParseEnum("C", e)); assert(e == E.c);