JSON structure

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

JSON structure

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which JSON snippet is valid?
A {"name": "Ava", "age": 17}
B {'name': 'Ava', 'age': 17}
2. Which brackets hold an ordered list of values in JSON?
A Square brackets [ ] make an array
B Curly braces { } make an array
3. Which JSON object stores a key-value pair correctly?
A {city = "Brisbane"}
B {"city": "Brisbane"}
4. Which line stores a boolean and a null correctly?
A {"active": true, "nickname": null}
B {"active": "true", "nickname": "null"}
5. How do you read the first item of this JSON array: ["red", "green", "blue"]?
A Items are unordered, so there is no first item
B Items are ordered, so "red" is first

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1{"name": "Ava", "year": 12} AThe number 88 and the boolean true are wrapped in quotes, so they are stored as strings rather than a number and a boolean
2["Maths", "English", "Science"] BJSON keys and strings must use double quotes, not single quotes
3Numbers, booleans and null are written without quotes, while strings need double quotes C{"age": 17, "active": true, "phone": null}
4Values can be nested: an object can hold an array, and an array can hold objects D{"students": [{"name": "Zoe"}, {"name": "Leo"}]}
5{'name': 'Ava'} EA JSON array: square brackets hold an ordered list of values separated by commas
6{"id": 1, "score": "88", "pass": "true"} FA JSON object: curly braces hold key-value pairs, with double-quoted keys and strings, separated by commas

Definitions

JSON object and array

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
{"name"_ "Ava", "year": 12}
2.
{"scores": _88, 74, 91]}
3.
{"age": 17, "isAdult": _____}
4.
{"name": "Zoe", "middleName": ____}
5.
{"pet": _"name": "Rex", "age": 3}}

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A {
B "name": "Ava",
C "age": 16,
D "active": True
E }
Question 2
A [
B "city": "Brisbane",
C "temp": 28
D }
Question 3
A {
B "id": 7,
C "tags": ["a", "b"],
D "note": nil
E }
Question 4
A {
B "scores": (88, 74, 91),
C "pass": true
D }
Question 5
A {
B user: {
C "name": "Liam"
D }
E }

Answer Key

JSON structure
Section A: Quick Questions
Q1
A — {"name": "Ava", "age": 17}
Q2
A — Square brackets [ ] make an array
Q3
B — {"city": "Brisbane"}
Q4
A — {"active": true, "nickname": null}
Q5
B — Items are ordered, so "red" is first
Section B: Match the Pairs
Q1
{"name": "Ava", "year": 12} → A JSON object: curly braces hold key-value pairs, with double-quoted keys and strings, separated by commas
Q2
["Maths", "English", "Science"] → A JSON array: square brackets hold an ordered list of values separated by commas
Q3
Numbers, booleans and null are written without quotes, while strings need double quotes → {"age": 17, "active": true, "phone": null}
Q4
Values can be nested: an object can hold an array, and an array can hold objects → {"students": [{"name": "Zoe"}, {"name": "Leo"}]}
Q5
{'name': 'Ava'} → JSON keys and strings must use double quotes, not single quotes
Q6
{"id": 1, "score": "88", "pass": "true"} → The number 88 and the boolean true are wrapped in quotes, so they are stored as strings rather than a number and a boolean
Section C: Definitions
Q1
JSON object and array — JSON stores data as key-value pairs inside {} objects and as ordered lists of values inside [] arrays. Keys are double-quoted strings. Values can be nested.
Section D: Fill in the Blanks
Q1
{"name": "Ava", "year": 12}
Q2
{"scores": [88, 74, 91]}
Q3
{"age": 17, "isAdult": false}
Q4
{"name": "Zoe", "middleName": null}
Q5
{"pet": {"name": "Rex", "age": 3}}
Section E: Spot the Error
Q1
D — JSON booleans must be lowercase. It should be "active": true. Capital-T True is Python, not JSON.
Q2
A — A JSON object of key-value pairs must open with a curly brace {, not a square bracket. It closes with }, so the brackets don't match.
Q3
D — JSON's empty value is null, not nil. The line should be "note": null.
Q4
B — JSON arrays use square brackets, not round brackets. It should be "scores": [88, 74, 91],.
Q5
B — Every JSON key must be a double-quoted string, even for a nested object. It should be "user": {.