Learn JMESPath

Projections, filters and built-in functions — the language behind the AWS CLI's --query.

The JMESPath cheat sheet

Basics

  1. Identifiers & missing values A JMESPath expression is a path: office.city reads city inside office, with no leading . or $. A key that…
  2. Array indexes [n] selects an element (zero-based); a negative number counts from the end.

Projections

  1. Slices [start:end:step] works like a Python slice: the end is exclusive, negative numbers count from the end, and…
  2. Projections: [*] and * [*] is JMESPath's central idea: a projection applies everything to its right to each element and gathers the…
  3. Flatten: [] [] flattens one level of nesting — and, like [*], it starts a projection.
  4. Pipes stop projections After a projection, everything to its right runs on each element. A pipe | ends the projection, so what…

Filtering

  1. Filters & literals [?condition] keeps the elements for which the condition is true. Numbers, booleans and null are written as…
  2. &&, || and ! && (and), || (or) and ! (not) combine tests inside a filter.
  3. Functions in filters Any function can appear in a condition, which is how you test text and arrays.

Reshaping

  1. Multiselect list [a, b, c] builds a list from several expressions — JMESPath's counterpart to jq's comma.
  2. Multiselect hash {key: expression, …} builds an object, so you can rename, pick and combine values.

Functions

  1. Counting & math length, avg, min, max and sum work on arrays (and length works on strings and objects too).
  2. Sorting & picking sort_by, min_by and max_by take an expression reference: &age means "evaluate age on each element" rather…
  3. Strings, join & map join(glue, list) builds a string, and map(&expr, list) applies an expression to every element.
  4. Types & defaults type names a value's type. a || b falls back to b when a is null, missing or empty, and not_null(a, b, …)…

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.