Joe Tsai 1f029180c7
types/jsonx: add package for json/v2 helpers (#15756)
The typical way to implement union types in Go
is to use an interface where the set of types is limited.
However, there historically has been poor support
in v1 "encoding/json" with interface types where
you can marshal such values, but fail to unmarshal them
since type information about the concrete type is lost.

The MakeInterfaceCoders function constructs custom
marshal/unmarshal functions such that the type name
is encoded in the JSON representation.
The set of valid concrete types for an interface
must be statically specified for this to function.

Updates tailscale/corp#22024

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2025-04-23 11:08:45 -07:00
..
2025-02-13 16:12:00 -08:00
2024-04-16 15:32:38 -07:00