A JSON object is an unordered collection of named fields. Each key is a string in double quotation marks, paired with a JSON value such as a number, string, Boolean, array, or another object. section 3.1.1
Nested book data
A book record can contain an author and title, while a person object contains a name and an array of books. Reordering an object's fields preserves the payload; reordering array elements does not. section 3.1.1
Listing 3.1 testdata/bookworms.json: Example of input file
[
{
"name": "Fadi",
"books": [
{
"author": "Margaret Atwood",
"title": "The Handmaid's Tale"
},
{
"author": "Sylvia Plath",
"title": "The Bell Jar"
}
]
},
{
"name": "Peggy",
"books": [
{
"author": "Margaret Atwood",
"title": "Oryx and Crake"
},
{
"author": "Margaret Atwood",
"title": "The Handmaid's Tale"
},
{
"author": "Charlotte Brontë",
"title": "Jane Eyre"
}
]
}
]
Inspect a complete JSON input file containing people, books, nested objects, strings, and arrays. section 3.1.1
Use JSON objects to exchange focused request data in an HTTP API:
- Define a Go request structure with a JSON field tag, such as a GuessRequest containing the guess field. section 8.2.3
- Decode the request body with json.NewDecoder and return a bad-request response when parsing fails. section 8.2.3






