Closed ls-sacchit-chadha closed 3 years ago
Unfortunately, no.
This will introduce an infinite loop, as codecgen tool will delegate to MarshalJSON/UnmarshalJSON methods if they exist on a given type and we are doing a json encode or decode. Consequently, if CodecEncodeSelf calls MarshalJSON which calls CodecEncodeSelf which calls MarshalJSON which calls ... (infinite loop).
Do not let them depend on each other. UnmarshalJSON is for types that can handle json encode/decode themselves. CodecEncodeSelf can handle encoding/decoding for any format, and is smart enough to delegate to UnmarshalJSON, etc if doing a json decode for example.
Hi, I am wondering if the codecgen tool can be used for for generating custom MarshalJSON and UnmarshalJSON methods for structs with fields having custom data types for e.g.
thank you!