Skip to content
CCNA 200-301 v1.1 reference — Automation and Programmability

JSON-encoded data

JSON objects, arrays and primitive types, nesting and syntax rules, and how to recognize valid versus invalid structures.

Objective 6.7v1.1 exam target

Objects, arrays and primitives

JSON (JavaScript Object Notation) is the dominant data-encoding format for APIs and configs: human-readable text representing objects {…} (key→value pairs), arrays […] (ordered lists), and primitives — string, number, boolean, null.

JSON components

ComponentSyntaxExample
Object{ "key": value, ... }{"vlan": 20}
Array[ value, value ][10, 20, 30]
String"quoted""access"
Numberbare digits1500 or -3.5
Booleantrue / false"enabled": true
nullnull"gateway": null
$ Annotated JSON
{Object open.
"interface": "GigabitEthernet0/1",String value — quotes required.
"enabled": true,Boolean — lowercase, unquoted.
"vlans": [10, 20, 30],Array of numbers.
"description": null,Null — explicit empty.
"ipv4": { "address": "192.168.10.1", "prefix": 24 }Nested object.
}No trailing comma allowed.

Valid versus invalid

Syntax errors that invalidate JSON

MistakeWhy invalid
Trailing comma{ "a": 1, } — JSON forbids them
Single quotes'text' — strings require double quotes
Unquoted keys{ vlan: 20 } — keys must be strings
Comments// note — JSON has no comments
True/None capitalizationTrue, None — must be true, false, null
Validate a response fragment
Candidate
{ "interfaces": [ { "name": "Gi0/1", "up": true, } ] }
  1. The object inside the array has a trailing comma after true.
  2. That single comma makes the whole document invalid JSON — a strict parser rejects it.
  3. Fix: remove the comma → { "name": "Gi0/1", "up": true }.

Strict syntax is the contract — one stray comma breaks the parse.

Verification

Verification cues

  • Use a parser, not eyes: python -m json.tool pretty-prints valid JSON or names the failing line.
  • Numbers vs strings matter: "vlan": "20" and "vlan": 20 are different types — API schemas enforce them.
  • Nesting depth is free-form — validate structure against the API's schema, not a guess.

Common mistakes

  • Reading { } as an array — braces are objects, brackets are arrays.
  • Adding trailing commas or comments — both are hard syntax errors.
  • Confusing JSON with Python dict reprs — None/True don't exist in JSON.
  • Assuming key order is preserved/semantically meaningful — objects are unordered.
API rejects a hand-edited payload

Observation: A curl POST returns 'invalid JSON' after a small manual edit.

Hypotheses
  • Trailing comma or unquoted key introduced
  • Smart quotes pasted from a document editor
  • A comment or trailing text left outside the structure
CheckIndicates
Run python -m json.tool on the payloadParser names the exact line/column of failure.
Diff against the last working versionThe edit introduced the invalid element.

Correction: Fix the syntax issue the parser reports.

The same payload parses cleanly, matches the schema, and the API accepts it.

On this page

Related resources

Sources

Targets CCNA 200-301 v1.1 objectives. Supplemental blocks are labeled beyond exam scope.

Search guided lessons, transcript chapters, flashcards, CLI drills and cheat sheets

JSON-encoded data | CCNA Study