Pocket Gophers

JSON References

2017-07-04

Chances are that if you have not had to deal with JSON data yet, you will. This is a collection of articles and talks that explain how to use encoding/json or one of the other JSON packages.

Overwhelmed by the 30+ references?

Learn how to handle any JSON with the Pocket Gophers’ Guide to JSON.

Advanced Encoding and Decoding Techniques

Jon Calhoun 2016-12-18

Explains how to solve two marshaling/unmarshaling problems: custom type encodings, and object types that are differentiated by the value of a common key.

Consuming JSON APIs with Go

Satish Manohar Talim 2015-10-04

Notes made as the author learned to consume numverify’s JSON REST API. Walks through the though and implementation process in two parts. Part 1 Part 2

Dealing With JSON With Non-Homogeneous Types In Go

Marko Mukulicic

This article uses an example of an integer that was encoded into JSON as either a string or a number to explain how to deal with situations where the encoded type may vary.

Decode JSON Documents In Go

William Kennedy 2014-01-21

Sometimes you don’t want or need all the data in a JSON document. This article explains a method to extract part of the data without having to unmarshal the entire structure.

Deliver my data, Mr. Json!

Christoph Berger video 2016-10-27

A tutorial to create a JSON client/server app. The article is a transcript of the video.

Dynamic JSON in Go

Tommi Virtanen 2015-08-27

Explains how to handle many kinds of JSON messages that are exchanged over the same communications channel. Deals with both encoding and decoding.

Dynamic JSON unmarshalling in Go new

Nathan Smith 2016-02-02

Explains how to deal with JSON fields that have different types depending on the context.

Encoding and Decoding JSON, with Go's net/http package

Kevin Burke 2016-02-11

Explains how to integrate encoding/json with net/http using the streaming API.

Go JSON tips new

A collection of tips that help solve particular problems when working with JSON.

Go JSON unmarshaling based on an enumerated field value

Tommi Virtanen 2016-01-12

Dealing with many JSON message types over the same communications channel can result in repetitive switch statements. This article describes a way to clean that up.

Go Walkthrough: encoding/json package

Ben Johnson 2016-08-22

Walks through the entire encoding/json package.

Go and JSON new

Zack Bloom

Explains how to parse JSON into a struct or an interface{}.

Go by Example: JSON

Example of JSON encoding and decoding, including how custom types.

Go json.Decoder Considered Harmful

Ahmet Alp Balkan 2016-04-28

Examines three pitfalls of using json.Decoder.

Golang basics - fetch JSON from an API new

Alex Ellis 2017-01-26

Tutorial starting from installing Go to fetching and parsing JSON data acquired from an API.

Golang: Working with JSON new

Abu Ashraf Masnun 2017-06-18

Learn how to create, parse, and stream JSON.

How to determine if a JSON key has been set to null or not provided

Jon Calhoun 2017-02-14

The method provided uses UnmarshalJSON on a non-pointer type that keeps track of its own validity.

JSON new

Bhawani Shanker 2017-03-14

Overview, with example, of basic JSON handling.

JSON Date management in Golang

Guillaume J. Charmes 2015-08-07

Explains how to deal with date formats and JSON.

JSON Decode into Objects

Edd Turtle 2015-08-01

An example showing how to take a JSON string and unmarshal it into an array of structs.

JSON Encode an Array of Objects

Edd Turtle 2015-08-01

An example showing how to marshal an array of structs into JSON.

JSON and Go

Andrew Gerrand 2011-01-25

The original introduction to encoding/json. Explains how to read and write any JSON from your Go program.

JSON and struct composition in Go

Attila Oláh 2014-09-10

Tips for using struct compostion for marshaling/unmarshaling JSON data.

JSON decoding in Go

Attila Oláh 2013-11-29

Explains some methods of unmarshaling JSON data that is not strictly typed, and therefore can’t be handled with struct tags.

JSON parsing in Golang

Jonathan M. H. 2016-03-28

Uses the JSON-encoded-rules from the PHP project slugify to explain how to unmarshal JSON data in Go.

JSON, interfaces, and go generate

Francesc Campoy video slides 2015-02-03

Explains how encoding/json uses interfaces to handle custom type encoding. Exploits those interfaces to generate handling for enum-like types like stringer does.

Load A JSON Configuration From File In A Golang Application new

Nic Raboy 2017-04-03

Explains how to deal with JSON in the context of loading configuration data.

Parsing json in Go

jeremywho 2016-11-15

Four increasingly complicated examples of unmarshing JSON data to Go types.

Smarter JSON Configs in Go new

Christ Mikkelson 2016-05-23

Shows how loading JSON into a struct can improve configuration file error handling.

Unmarshaling a JSON array into a Go struct new

Tommi Virtanen 2016-01-13

Describes a method to unmarshal a heterogeneous JSON array into a typed Go struct.

Working with JSON in Go new

Elliot Chance 2016-05-28

Explains how to avoid []interface{} and map[string]interface{} when working with JSON.


As I find more references, I will update this page. To be notified when this page is updated, please subscribe.

Dig into the Fundamentals of Go

Subscribe to receive a weekly email covering a Go fundamental. Be it the language, its tooling, or its packages, you will learn what you need to know.