Visual RFC.
ALL RFCs / RFC 8259
Read the RFC ↗
RFC 8259 / JSON BUILDING BLOCKS

Should we find a value by its name or its place?

02

Move named drawers and reorder a queue to see why objects and arrays mean different things.

RFC 8259 · § 4EXAMPLE
1 / 4 · Names and positions answer different questions

A named drawer answers “Which value is called pet?” A queue answers “Which value is first?”

Drawers have names

cat
fish

What happens if you change this?

Make one change, then watch again. Restart restores the original example.

3 / 3
03
Avoid ambiguous mappings.

Two members named role can produce different results in different implementations.

Should we find a value by its name or its place?Object members are selected by string names, array elements by ordered position; duplicate object names are shown as an interoperability hazard.Objects use names; arrays use positionsIllustrative JSON structures"name": "Ada","active": trueRead a member by its name, not its display order[]"red",index 03,index 1trueindex 2{"role":"reader", "role":"admin"}Duplicate names: consumers may disagreePrefer unique names for interoperable mappings

Key idea: Use unique names to find named values; use an array when order matters.

Terms
JSON
JavaScript Object Notation: shared rules for writing data as text. Apps in many languages use it.
Object
A group of named values, like drawers with different labels.
Array
A list whose values have meaningful positions.
String
A text value between quotation marks.
Grammar
Rules for which marks and words may appear and where.
Interoperability
Different apps can read the same data and agree about its meaning.

Look up a term in the glossary ↗

Rules & examples

Use unique names for members and positions for ordered elements.

  • Object names are strings; a colon separates name and value, and commas separate members. Names should be unique.
  • An array is ordered, can be empty, and may mix value types.
  • Applications that depend on object-member order are less interoperable because parsers expose that order differently.

Duplicate object names can be accepted by the grammar but produce incompatible consumer behavior: last value, all values, or an error. Use unique names to avoid this ambiguity.

RFC 8259 §4 recommends unique names (SHOULD), rather than making duplicates a grammar error. Object member ordering may be exposed differently. §5 arrays are ordered and may mix value types. The three duplicate-reader outputs shown are examples, not one mandated policy.

Sources
Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

First, agree how to read the message.

An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

All chapters in RFC 8259

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗