All Products
Search
Document Center

Resource Orchestration Service:Fn::Jq

Last Updated:Jun 17, 2026

Fn::Jq uses jq syntax to filter values in a JSON string.

Declaration

  • JSON

    {
      "Fn::Jq": [
        method,
        script,
        object
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::Jq: method,script,object
    • Syntax for the short form:

      !Jq [method,script,object]

Parameters

  • method: Required. String.

    Valid values:

    • First: the first value that matches the filter

    • All: all values that match the filter

  • script: Required. String. The jq script to use as a filter for the JSON string. For more information about jq, see jq Manual (development version).

  • object: Required. The JSON string to filter.

Return value

The filtered values from the JSON string.

Examples

Single filter

This example returns the first value matched by the .test filter. The value at the test key in the JSON string is returned. If the value does not exist, null is returned.

!Jq
  - First
  - .test
  - '{"test":"test"}'

Result:

test

Multiple filters

Note

Separate multiple filters with vertical bars (|).

This example pipes the output of the .parameters[] filter into a second filter by using a vertical bar (|). The .parameters[] filter extracts each element from the parameters array, and the second filter {"param_name": .name, "param_type":.type} reshapes each element into an object with param_name and param_type keys. If no values match, null is returned.

!Jq
  - All
  - '.parameters[] | {"param_name": .name, "param_type":.type}'
  - changeSet:
      items: []
      kind: git
    id: 2013-12-27_00-09-37
    parameters:
      - name: PKG_TAG_NAME
        value: trunk
      - name: GIT_COMMIT
        value: master
      - name: TRIGGERED_JOB
        value: trunk-buildall

Result:

- param_name: PKG_TAG_NAME
- param_name: GIT_COMMIT
- param_name: TRIGGERED_JOB