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
Supports parsing, validating, and producing JSON in a configuration and format-conversion CLI.
How deep it goes
Works through struct tags and unmarshaling, then shows custom methods for validation and redaction.
Examples
Uses a server configuration JSON file, a tagged Config struct, host URL validation, and host redaction.
What you can do after
Build it from scratch: decode a JSON configuration into a Go struct and customize validation or serialized output.

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.