JSON is a text-based format for structured data. It stores key-value pairs: keys are strings, while values can be numbers, strings, arrays, booleans, or objects. Object fields are unordered; array elements are ordered. section 3.1.1
A practical Go workflow opens a JSON file, maps its structure to exported Go structs, and decodes it with encoding/json. Struct tags connect Go fields to JSON field names. section 3.1.3
When loading JSON in Go:
- Define exported fields whose tagged structure matches the JSON data. section 3.1.3
- Keep test data in a testdata directory, which the go tool ignores during compilation. section 3.1.1
Bookworm collections
A JSON array can contain objects with nested arrays: [{"name":"Fadi","books":[{"author":"Margaret Atwood","title":"The Handmaid's Tale"}]}]. Matching Go types use Bookworm with Name and Books fields, and Book with Author and Title fields, each connected by json tags.


































