Talk Notes: Advanced JSON Handling in Go
March 5, 2020
Go JSON Tricks: The Self-Referencing Marshaler
For more content like this, buy my in-progress eBook, Data Serialization in Go, and get updates immediately as they are added! The content in this post is included in my in-progress eBook, Data Serialization in Go, available on LeanPub. I’ve done a lot of JSON handling in Go. In the process, I’ve learned a number of tricks to solve specific problems. But one pattern in particular I find myself repeating ad infinitum.
Go JSON Tricks: Extending an Embedded Marshaler
This post is an excerpt from my in-progress book, Data Serialization in Go, available on LeanPub. Back in 2016, when I was still fairly new to Go, I asked a question on StackOverflow about how to properly marshal a struct which embeds a struct with a custom MarshalJSON method. I got a few answers that helped point me in the right direction, but to this day I never received a completely satisfactory answer, that allows extending the existing MarshalJSON method, without duplicating it.