A new Go API for JSON

22 points by binjip978


thiht

I really love that Go figured a way to version the stdlib without making breaking changes and in a way that’s natural with Go modules major versions. Just having /v2 paths feels really simple and elegant to me

Anyway to stay on topic, my favorite change about json/v2 is definitely how it makes it possible (and even defaults) to serialize nil slices / maps as empty JSON arrays / objects instead of null. This was long overdue and makes it much easier when working with Typescript on the consumer end of an API

fanf

This has been in the works for over a year so there have been articles about it previously (25 comments), previously, previously; from a quick skim of this article I can’t see a summary of what has changed since last year.

xilef

I recently migrated a reasonably JSON-heavy set of services to the V2 and it went very smoothly. The one thing that caught us was the lack of newlines in generated JSON, but that forced us to inspect our tests again so not a bad thing.