diff --git a/source/mir/deser/package.d b/source/mir/deser/package.d index 438e955..72e2deb 100644 --- a/source/mir/deser/package.d +++ b/source/mir/deser/package.d @@ -1360,7 +1360,8 @@ template deserializeValue(string[] symbolTable, TableKind tableKind) return retNull; } } - static if ((contains!(typeof(null)) || contains!IonNull) && T.AllowedTypes.length == 2) + static if (T.AllowedTypes.length == 2 + && (contains!(typeof(null)) || contains!IonNull || is(T.AllowedTypes[0] == void))) { T.AllowedTypes[1] payload; if (auto exception = deserializeValue(data, payload, table, tableIndex)) diff --git a/source/mir/ion/examples.d b/source/mir/ion/examples.d index 6b3d543..7d4ffc5 100644 --- a/source/mir/ion/examples.d +++ b/source/mir/ion/examples.d @@ -1408,7 +1408,7 @@ version(mir_ion_test) unittest version(mir_ion_test) unittest { import mir.serde: serdeEnumProxy; - import mir.algebraic: Nullable, nullable; + import mir.algebraic: Nullable, Variant, nullable; @serdeEnumProxy!string enum StrE : string @@ -1420,13 +1420,15 @@ version(mir_ion_test) unittest static struct S { Nullable!(StrE[]) a; + Variant!(void, StrE) b; } import mir.ser.json : serializeJson; import mir.deser.json : deserializeJson; auto s = S([StrE.one, StrE.two, cast(StrE)"drei"].nullable); - auto str = `{"a":["eins","zwei","drei"]}`; + s.b = StrE.two; + auto str = `{"a":["eins","zwei","drei"],"b":"zwei"}`; assert(str.deserializeJson!S == s); assert(s.serializeJson == str, str);