You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/types/jsonx
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>
7 months ago
..
json.go types/jsonx: add package for json/v2 helpers (#15756) 7 months ago
json_test.go types/jsonx: add package for json/v2 helpers (#15756) 7 months ago