jq · lesson 1 of 32 · Getting started
Identity & fields
A jq program is a filter: it takes the input document and produces zero or more outputs. . is the simplest filter and .name reads a field.
Examples
Example 1The whole input, unchanged
Document
{ "name": "Ada", "age": 36 }Query
..The identity filter: returns its input as it is. Handy for seeing (or pretty-printing) a whole document.
Result
{"name":"Ada","age":36}Example 2One field
Document
{ "name": "Ada", "age": 36 }Query
.name.nameField access: the value stored under the keynamein the current input.
Result
"Ada"
Good to know
- Press Ctrl+Enter in the playground to run a query. Every output is a result of its own.
.nameis shorthand for.["name"]— the next lesson covers keys that aren't plain identifiers.