JQ task

Use a JQ task to transform JSON without calling another service. JQ is a compact language for selecting and changing JSON data.

The complete input and output must each fit within 32 MiB, as well as the applicable task-data and file-input allowances. Loading input from a file does not bypass this fixed limit. Select fewer fields or split the work into smaller operations when it is too large.

jq-filter.png

Enter the JQ filter in Expression and provide the JSON it receives through Input Parameters. When it runs, the filter transforms that input for later tasks. Check field availability and the output shape, and reserve JQ for transformation rather than side effects.

For example, use JQ to change an order input into the smaller JSON object an Email task needs. Do not use it for HTTP calls, notifications, or work a person must complete.

Field

Required

Default Value

Description

Expression

Yes

N/A

The JQ program run against the task input. Its results are returned in the task output's result and resultList fields.

Use ${['Transform data'].output.result} to read the first value returned by a JQ task named Transform data, or ${['Transform data'].output.resultList} to read all returned values. When the filter returns no values, result is null and resultList is empty. Replace the task name with the name in your workflow.

Example: prepare the next task's data

For a JQ task named Prepare notice, map {"request":"${workflow.input.request}"} into Input Parameters. Suppose that selected request is:

{
  "requestId": "REQ-104",
  "amount": 1250,
  "internalNote": "Not needed in the notice"
}

Enter .request | {requestId, amount} in Expression. The result excludes the note:

{
  "result": {
    "requestId": "REQ-104",
    "amount": 1250
  },
  "resultList": [
    {
      "requestId": "REQ-104",
      "amount": 1250
    }
  ]
}

Map ${['Prepare notice'].output.result} into a later task when it needs that object. For example, {"notice":"${['Prepare notice'].output.result}"} makes ${notice.requestId} available in an Email task. Test with representative input; missing fields, the wrong input shape, or a large result need a corrected mapping/filter, not a provider credential. Select fewer fields rather than returning an entire large document. See Limits and recovery before processing files.

Test with input parameters

Click Test with Input Parameters to run the current filter against the current task input and inspect the result before publishing. Testing does not save, publish, or start the workflow.

Example

Required filter is a JQ program, not a ${...} placeholder. It runs against the captured input JSON object. Supported top-level file-reference parameters load original UTF-8 text, including JSON, YAML, HTML, XML and CSV. They do not parse those formats. Use fromjson explicitly for JSON text, or JSON Converter first for a structured YAML, XML or CSV file. Malformed JSON can be loaded as text; fromjson is the step that rejects invalid JSON.

Configure the example using its visible controls:

Select JQ Task and open JQ Filter. Enter {requestId: .requestId, amount: .amount} in Expression. Supply requestId and amount through Input Parameters or the preceding output. Use Test with Input Parameters to inspect the result before publishing; testing does not start the workflow.

example-jq-task.png

Input

Captured task data after Input Parameters mapping:

{
  "requestId": "REQ-104",
  "amount": 1250
}

Output

Always result plus resultList. result is the first yielded JSON value; resultList is every yielded value in order. With no values (empty), output is {"result":null,"resultList":[]}. A yielded null gives [null] in the list. Filter [1,2] yields result:[1,2], resultList:[[1,2]]; filter 1,2 yields result:1, resultList:[1,2]. An empty array is one value, not no values.

Raw task output:

{
  "result": {
    "requestId": "REQ-104",
    "amount": 1250
  },
  "resultList": [
    {
      "requestId": "REQ-104",
      "amount": 1250
    }
  ]
}

When something goes wrong: Map output.result for one transformed value and output.resultList when you need every yield. Fix an invalid filter, missing mapped fields or unsupported file type. Input and complete output must fit their limits; large JQ output fails rather than automatically becoming a file.

A following task can map this value: ${['Transform data'].output.result}.