JSON Pointer · lesson 5 of 6 · When it doesn't work
What pointers can't do
A pointer names one exact location. There is no negative index, no wildcard and no filter — for those, use JSONPath, jq or JMESPath.
Examples
Example 1No negative indexes
Document
{
"store": {
"book": [
{ "title": "Moby Dick", "price": 8.99 },
{ "title": "Ulysses", "price": 12.5 }
],
"bicycle": { "color": "red" }
}
}Query
/store/book/-1-1RFC 6901 has no negative indexes (jq has.[-1], JSONPath[-1]).
Result (it fails on purpose)
query error: no value at pointer '/store/book/-1'
Example 2No wildcards
Document
{
"store": {
"book": [
{ "title": "Moby Dick", "price": 8.99 },
{ "title": "Ulysses", "price": 12.5 }
],
"bicycle": { "color": "red" }
}
}Query
/store/book/*/title**is looked up as an ordinary key literally named*, which doesn't exist.
Result (it fails on purpose)
query error: no value at pointer '/store/book/*/title'
Good to know
- A lone
-(as in/store/book/-) means "the position after the last element" — meaningful when adding with JSON Patch, but never a readable value. - Want every title? JSONPath:
$.store.book[*].title· jq:.store.book[].title· JMESPath:store.book[*].title.