Go JSON unmarshaling based on an enumerated field value
In a previous article , we talked about marshaling/unmarshaling JSON with a structure like
{
"type": "this part tells you how to interpret the message",
"msg": ...the actual message is here, in some kind of json...
}
Last time, we left a repetitive switch statement in the code, where each message type was unmarshaled very explicitly. This time, we'll talk about ways to clean that up.