liveBook · Manning

Encoding/json

encoding/json is Go’s standard-library package for encoding Go values as JSON and decoding JSON into Go values.

How 2 Manning books explain it

Learn Go with Pocket-Sized Projects

encoding/json is Go's standard-library package for encoding and decoding JSON data.

How it is used
Parses structured JSON files and messages into Go values while also supporting the reverse encoding direction.
How deep it goes
Explains structure matching, tags, exported fields, streaming decoding, and errors, while deferring detailed HTTP response decoding.
Examples
Demonstrates decoding a bookworm-and-books JSON file into tagged Go structures and printing the resulting slice.
What you can do after
Apply via encoding/json to decode files into exported, tagged Go structures and handle failures returned by the decoder.

Read how Learn Go with Pocket-Sized Projects explains encoding/json →

Go in Action, Second Edition

encoding/json is Go's standard-library package for encoding Go values as JSON and decoding JSON into Go values.

How it is used
Processes JSON in configuration and data-exchange workflows, including a JSON/XML validation and conversion CLI.
How deep it goes
Explains struct tags and unmarshaling, then demonstrates custom serialization methods for validation and redaction.
Examples
Uses a server configuration with name, port, and host fields, including host validation and redaction.
What you can do after
Apply encoding/json to decode and encode structured Go values and customize their JSON representation.

Read how Go in Action, Second Edition explains encoding/json →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.