JSON Pointer · lesson 2 of 6 · Basics
Keys & array indexes
The same /token syntax indexes arrays: use the zero-based position. Numbers aren't special on objects — there /10 is simply the key "10".
Examples
Example 1An array element
Document
{
"store": {
"book": [
{ "title": "Moby Dick", "price": 8.99 },
{ "title": "Ulysses", "price": 12.5 }
],
"bicycle": { "color": "red" }
}
}Query
/store/book/0/title
/bookThebookarray./0An array index: zero-based, so0is the first element./titleItstitle→"Moby Dick".
Result
"Moby Dick"
Example 2A number used as an object key
Document
{ "10": "ten", "list": ["a", "b"] }Query
/10/10On an object,10is just a key name; the same token on an array would be an index.
Result
"ten"
Good to know
- Indexes have no sign and no leading zeros:
/list/01and/list/+1don't match anything.