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
- 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
- packagekind of · A software package is a named unit that groups related code and may serve as a namespace, compilation unit, or distributable bundle.
- JSONuses · JSON is a language-independent text-based data-interchange format that represents values as objects, arrays, strings, numbers, booleans, 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.
- Mapuses · A map is an associative data structure that stores key-value pairs and uses keys to identify and access associated values.
- encodingimplements · Encoding is the process or scheme of mapping information into a different representation according to defined rules for storage, processing, transmission, or interpretation.
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.

