Have you ever interact with an API that returns variable data formats depending on the circumstances? Yeah, it's a pain. In this post we explore one particular situation - when the response can either be an array or a single item - and look at how to handle unmarshaling the JSON in Go.
A common misconception is that a JSON API is vastly different from a web application that renders server-side HTML. In this article we explore how to convert an HTML-based web app into a JSON API in order to demonstrate how similar the two really are in a well designed app.
Learn to distinguish between when a JSON key is set to null or the key wasn't provided at all when dealing with JSON in Go.
Jon Calhoun is a full stack web developer who also teaches about Go, web development, algorithms, and anything programming related. He also consults for other companies who have development needs. (If you need some development work done, get in touch!)
Jon is a co-founder of EasyPost, a shipping API that many fortune 500 companies use to power their shipping infrastructure, and prior to founding EasyPost he worked at google as a software engineer.
Jon's latest progress update: Writing Course Notes
©2018 Jonathan Calhoun. All rights reserved.