Encoding/json
encoding/json is Go’s standard-library package for encoding Go values as JSON and decoding JSON into Go values.
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
- packagekind of · A package is a programming-language namespace and organizational unit that groups related code and may define import, compilation, or access boundaries.
- JSONuses · JSON is a standardized, language-independent text format for representing structured data using objects, arrays, strings, numbers, Boolean values, and null.
- standard librarypart of · A standard library is a collection of reusable modules, types, functions, APIs, and other facilities distributed with a programming language implementation or platform.
- struct taguses · A struct tag is metadata attached to a Go struct field that guides reflection-based processing such as serialization and field mapping.
- serializationuses · Serialization is the encoding of structured data or in-memory values into a representation suitable for storage or transmission and later reconstruction.
- Mapuses · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
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.

