Hacker News new | ask | show | jobs
by alyandon 2070 days ago
Lovely - I can't wait to see how horrible something like that is to implement in a language like Go.
4 comments

You 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.

Sounds like a golang problem. Rust can easily handle it with union types from what I have seen.
I hope you enjoy working with interface{}

_sigh_

interface{} to the rescue