3 ms·
Lovely - I can't wait to see how horrible something like that is to implement in a language like Go.
by alyandon 6y ago
Lovely - I can't wait to see how horrible something like that is to implement in a language like Go.
- nullandvoid 6y agointerface{} to the rescue
- meddlepal 6y agoI hope you enjoy working with interface{} _sigh_
- CameronNemo 6y agoSounds like a golang problem. Rust can easily handle it with union types from what I have seen.
- dullgiulio 6y agoYou have to implement UnmarshalJSON. Between each attempt to deserialize into a possible struct, be careful to return on errors that are not JSON serialisation errors (for example caused by reading from the underlying Reader, etc.) It's ugly and verbose but there is no need to use empty interface.