3 ms·
There are surprisingly many ways to do JSON in Go. There's reflection with the stdlib as well as keeping parts of it as "raw" byte slices; code generation with
by wvh 7y ago
There are surprisingly many ways to do JSON in Go. There's reflection with the stdlib as well as keeping parts of it as "raw" byte slices; code generation with packages like ffjson and easyjson; practically hand-built with gojay; the approach of a state machine on a simple byte string like gjson and jsonparser; and then through templates like e.g. quicktemplate. The best approach really depends on what you want to do.
I think these sorts of challenges show that Go tends to be used in lower-level code than typical dynamic languages. I've combined three or four different approaches in several Go projects, which I couldn't imagine doing in a language like Python.