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

.
  1. . The identity filter: returns its input as it is. Handy for seeing (or pretty-printing) a whole document.

Result

{"name":"Ada","age":36}

Try it in the playground

Example 2One field

Document

{ "name": "Ada", "age": 36 }

Query

.name
  1. .name Field access: the value stored under the key name in the current input.

Result

"Ada"

Try it in the playground

Good to know

  • Press Ctrl+Enter in the playground to run a query. Every output is a result of its own.
  • .name is shorthand for .["name"] — the next lesson covers keys that aren't plain identifiers.

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.