Tangible Bytes

A Web Developer’s Blog

Unstructured JSON to Golang

I really like the way Go imports json into its own data structures.

You just define a struct, annotate it to map the JSON field names to the struct field names (taking care to follow the Go convention of using Capitalised initials where the field is public).

There are also some great tools to automatically generate the struct from JSON

eg Convert JSON to Go struct

But where I got stuck was with JSON that is flexible and doesn’t match something I can directly make in Go.

Read more ...