Ejemplos
All data in object
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}]
{"color":"red","price":19.95}
[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]- Consulta
$.store.*- Delimitador de resultado
All elements in array which meet condition
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99}
{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99}
{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}- Consulta
$..book[?(@.price<30 && @.category=="fiction")]- Delimitador de resultado
All elements in array with property
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99}
{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}- Consulta
$..book[?(@.isbn)]- Delimitador de resultado
All elements in object
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95}
{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99}- Consulta
$..book[?(@.price<10)]- Delimitador de resultado
Empty expression
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
Empty result- Consulta
(empty)- Delimitador de resultado
Fetch of all values with matching key
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
"Sayings of the Century"
"Sword of Honour"
"Moby Dick"
"The Lord of the Rings"
"Financial Times"
"The Guardian"- Consulta
$..title- Delimitador de resultado
Fetch of values from specific object
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
"Nigel Rees"
"Evelyn Waugh"
"Herman Melville"
"J. R. R. Tolkien"- Consulta
$.store.book[*].author- Delimitador de resultado
First 2 elements in array
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95}
{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99}- Consulta
$..book[:2]- Delimitador de resultado
Last element in array
Entrada
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95},"newspaper":[{"format":"broadsheet","title":"Financial Times","price":2.75},{"format":"tabloid","title":"The Guardian","price":2}]}}Expected answer
JSON{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}- Consulta
$..book[-1:]- Delimitador de resultado
Empty JSON
Entrada
Expected rejection
Message containsInvalid input JSON:- Consulta
(empty)- Delimitador de resultado
Parámetros
| Parámetro | Valor predeterminado | Entrada y opciones |
|---|---|---|
| Consulta | "" | Texto |
| Delimitador de resultado | "\\n" | Se admiten secuencias de escape como \n, \r y \t |