Dynamic JSON in Go

Go is a statically typed language. While it can represent dynamic types, making a nested map[string]interface{} duck quack leads to very ugly code. We can do better, by embracing the static nature of the language.

The need for dynamic, or more appropriately parametric, content in JSON often arises in situations where there's multiple kinds of messages being exchanged over the same communication channel. First, let's talk about message envelopes, where the JSON looks like this:

	"type": "this part tells you how to interpret the message",
	"msg": ...the actual message is here, as some kind of json...


  • go
  • json
  • programming
  • article