Skip to content

JQ Query (Parse JSON)

JQ Query (Parse JSON) selects and reshapes the information in the data it receives. You write a short query that says which fields you want and how they should look, and the component returns only that.

It’s useful when a service sends back very large responses and you only care about a few fields, or when you need to filter items that meet a condition.

When to use it

  • Keep only the name and email of each contact from a response with dozens of fields.
  • Filter the orders whose status is “pending”.
  • Rename fields so they match what the next component expects.
  • Pull out a list that sits inside another response so you can go through it later.

Configuration

FieldWhat it does
Input (required)The data or message you want to filter. If it’s a message, its text must be structured data.
JQ Query (required)The query. What the component receives is always a list, so queries usually start with .[], which means “each item”.
Flatten Data recordsOff by default. If you turn it on and the input is a list of records, the query is applied to each record separately and the fields it returns are added to that record, which keeps the ones it already had.
Remove Empty KeysOff by default. Removes empty fields and lists with no items from the result. Use it together with Flatten Data records.

Some example queries you can write in JQ Query:

You want…Query
Only the name and email of each contact.[] | {name: .name, email: .email}
Only the pending orders.[] | select(.status == "pending")
The items of a list that sits inside the response.[] | .items[]

Output

The Filtered Data output returns one record per query result. If a result is a simple value (a text or a number), you get it in the text field. You can connect it to a Loop, to Parse Data or to any component that takes records.

Example

A flow queries a store’s catalog and gets each product with more than 40 fields. To send an agent only what matters, JQ Query (Parse JSON) uses the query .[] | {product: .title, price: .price, stock: .inventory}. The agent receives records with three fields and answers faster.