Seleção básica
Selecione elementos usando uma barra (/). Selecione itens da matriz usando colchetes ([]).
A tabela a seguir mostra exemplos de uma seleção básica de elementos JSON.
| Exemplo | Descrição | Estado | Expressão | Resultado |
|---|---|---|---|---|
| Primitiva | Seleciona uma primitiva JSON. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object/attr1 |
"value1" |
| Novo em V2 Índice de String | Seleciona um caractere de uma sequência. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object/attr1[0] |
"v" |
| Objeto | Seleciona um objeto JSON. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object |
{ "attr1": "value1", "attr2": "value2" } |
| Array | Seleciona uma matriz JSON. | { "array": [ "value1", "value2" ] } |
/array |
[ "value1", "value2" ] |
| Índice de Matriz | Seleciona um item de uma matriz JSON por índice. O índice começa em 0. | { "array": [ 1.1, 2.2 ] } |
/array[1] |
2.2 |
| Aninhados | Seleciona um atributo de um objeto que é aninhado em uma matriz. | { "array": [ { "id": 123 }, { "id": 456
} ] } |
/array[1]/id |
456 |
| Diversos aninhados | Seleciona todos os atributos de um objeto que é aninhado em uma matriz. | { "array": [ { "id": 123 }, { "id": 456
} ] } |
/array/id |
[ 123, 456 ] |
| Chaves de aspas simples | Seleciona nomes de chaves usando aspas simples. | { "name with spaces": { "some attribute": true, "another attribute":
false } } |
/'name with spaces'/'some attribute' |
true |
| Chaves de aspas duplas | Seleciona nomes de chaves usando aspas duplas. | { "name with spaces": { "some attribute": true, "another attribute":
false } } |
/"name with spaces"/"some attribute" |
true |
| Suporte a Unicode | Seleciona usando chaves e valores Unicode. | { "a͓̽t͓̽t͓̽r͓̽": "v͓̽a͓̽l͓̽u͓̽e͓̽" } |
/"a͓̽t͓̽t͓̽r͓̽" |
"v͓̽a͓̽l͓̽u͓̽e͓̽" |