Select an array element
03An array interprets a token as a zero-based index, with strict rules for its spelling and bounds.
The result is B. The alternative array tokens 01, - and 3 do not resolve elements of this three-item array.
Source for this drawing: RFC 6901 · Read RFC section 4 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
- Zero-based index
- A position count beginning with 0 for the first element.
- Scalar
- A non-container JSON value such as a string, number, boolean or null.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Interpret each token using the type of the current value.
- An array index is 0 or an unsigned base-10 integer without a leading zero. Index 0 selects the first element; the array token MUST follow the index rules or be the single character -.
- The - token denotes the nonexistent position after the final element. It always fails to resolve a concrete array value under JSON Pointer alone; an application must separately define useful handling for it.
- Invalid indices, out-of-range indices, nonexistent object members and attempts to descend through a scalar cannot resolve a concrete value. Evaluation fails; any recovery or mutation behavior belongs to the application, not to JSON Pointer itself.
The example is {"items":["A","B","C"]}, so /items/1 selects B. The spelling 01 can be an object member name, but not an array index. A pointer is not guaranteed to exist, and resolving one is not an authorization check.
Read the RFC section ↗