Skip to Main Content
The Go Workshop
book

The Go Workshop

by Delio D'Anna, Andrew Hayes, Sam Hennessy, Jeremy Leasor, Gobin Sougrakpam, Dániel Szabó, Philipp Mieden, David Parker, Gwenn Etourneau, Arpit Aggarwal, Eugene Wang
December 2019
Beginner content levelBeginner
824 pages
14h 36m
English
Packt Publishing
Content preview from The Go Workshop

11. Encoding and Decoding (JSON)

Overview

This chapter aims to acquaint you with the fundamentals of JavaScript Object Notation (JSON). You will learn how to use Go to parse JSON, and then gain the ability to convert JSON to a struct and back to JSON.

Here, you will learn to describe JSON and unmarshal JSON to a struct. You will also learn to marshal a struct to JSON and set the JSON key name to something different than the struct field name. By the end of the chapter, you will be able to use various JSON tag attributes to control what gets converted to JSON, unmarshal an unknown JSON structure, and use encoding for data transmission.

Introduction

In the previous chapter, we looked at errors in Go and discovered that, in Go, errors are ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing, Presenting, and Communicating with Confidence

Writing, Presenting, and Communicating with Confidence

Harvard Business Review
Become a Better Problem Solver by Telling Better Stories

Become a Better Problem Solver by Telling Better Stories

Arnaud Chevallier, Albrecht Enders, Jean-Louis Barsoux

Publisher Resources

ISBN: 9781838647940Supplemental Content