getty-zig / getty

A (de)serialization framework for Zig
https://getty.so
MIT License
200 stars 13 forks source link

Add support for 'untagged' attribute #109

Closed ion232 closed 1 year ago

ion232 commented 1 year ago

Problem

Currently, it's not possible to make the following deserialization with getty-json:

Json:

[0, "zero"]

Zig:

pub const Tuple = union(enum){
    integer: i64,
    string: []u8,
};

try json.fromSlice(allocator, []Tuple, s);

Proposal

Add support for an untagged attribute, so that tagged unions can be serialized as untagged values, and be deserialized from untagged values.

Alternatives

No response

Additional Context

No response