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
  1. /book The book array.
  2. /0 An array index: zero-based, so 0 is the first element.
  3. /title Its title → "Moby Dick".

Result

"Moby Dick"

Try it in the playground

Example 2A number used as an object key

Document

{ "10": "ten", "list": ["a", "b"] }

Query

/10
  1. /10 On an object, 10 is just a key name; the same token on an array would be an index.

Result

"ten"

Try it in the playground

Good to know

  • Indexes have no sign and no leading zeros: /list/01 and /list/+1 don't match anything.

About jsonquery

Query, format and learn JSON with jq, JSONPath, JMESPath and JSON Pointer. It is the engine of the desktop app, run in your browser.

Engine
The desktop app’s, compiled to WebAssembly
Licence
MIT (the engine and the app)
Source
GitHub
Contact
The contact form (private)
Public issues
GitHub
Legal
Privacy policy

Known limitations: a file over 10 MB opens read-only and one over 512 MB does not open here; the desktop app has no such limit.