Supported jq Features

The Rapid Adapter Builder platform supports a subset of jq features, as specified in this topic.

See the jq Manual for the complete list of jq functions. Read the limitations applicable for jq 1.6.

The Rapid Adapter Builder platform supports the following jq features:

Basic Filters

  • .
  • .foo, .foo.bar
  • .[<string>], .[2], .[10:15]
  • .[]
  • .[]?
  • ,
  • ¿

Types and values

  • Array construction - []
  • Objects - {}

Built-in operators and functions

  • Addition - +
  • Subtraction - -
  • Multiplication, division, modulo - *, /, and %
  • length
  • keys, keys_unsorted
  • has(key)
  • in
  • path(path_expression)
  • del(path_expression)
  • to_entries, from_entries, with_entries
  • select(boolean_expression)
  • arrays, objects, iterables, booleans, numbers, normals, finites, strings, nulls, values, scalars
  • empty
  • error(message)
  • map(x), map_values(x)
  • paths, paths(node_filter), leaf_paths
  • add
  • any, any(condition), any(generator; condition)
  • all, all(condition), all(generator; condition)
  • flatten, flatten(depth)
  • range(upto), range(from;upto) range(from;upto;by)
  • floor
  • sqrt
  • tonumber
  • tostring
  • type
  • infinite, nan, isinfinite, isnan, isfinite, isnormal
  • sort, sort_by(path_expression)
  • group_by(path_expression)
  • min, max, min_by(path_exp), max_by(path_exp)
  • unique, unique_by(path_exp)
  • reverse
  • contains(element)
  • indices(s)
  • index(s), rindex(s)
  • inside
  • startswith(str)
  • endswith(str)
  • combinations, combinations(n)
  • ltrimstr(str)
  • rtrimstr(str)
  • explode
  • implode
  • split
  • join(str)
  • ascii_downcase, ascii_upcase
  • recurse(f), recurse, recurse(f; condition), recurse_down
  • walk
  • ..
  • setpath, delpaths, getpath
  • utf8bytelength
  • transpose
  • String interpolation - \(foo)
  • Convert to/from JSON
  • Format strings and escaping
  • Dates

Conditionals and comparisons

  • ==, !=
  • if-then-else
  • >, >=, <=, <
  • and/or/not
  • Alternative operator - //
  • try-catch

Regular expressions (PCRE)

  • test(val), test(regex; flags)
  • match(val), match(regex; flags)
  • capture(val), capture(regex; flags)
  • scan(regex), scan(regex; flags)
  • split(regex; flags)
  • splits(regex), splits(regex; flags)
  • sub(regex; tostring) sub(regex; string; flags)

Advanced features

  • Variables

    Use brackets to ensure operator precedence.

  • Defining Functions

    Avoid duplicate function names.

  • Reduce
  • limit(n; exp)
  • first(expr), last(expr), nth(n; expr)
  • first, last, nth(n)
  • foreach
  • Recursion

    Up to five levels.

  • Generators and iterators

Math

Assignment

  • =
  • |=
  • +=, -=, *=, /=, %=, //=
  • Complex assignments

Sample code showing how to use jq features

to_entries

Examples:

Input json Expression in adapter definition document Output json
{
"potato": true,
"broccoli": false
}
{
"uri": "http://surveyUrl.com",
"method": "POST",
"body": "${ {vegetableFeedback : .input|to_entries } }"
}
{
...
  "body" : {
    "vegetableFeedback" : [ {
      "key" : "potato",
      "value" : true
    }, {
      "key" : "broccoli",
      "value" : false
    } ]
  }
}

from_entries

Examples:

Input json Expression in adapter definition document Output json
{
"vegetables": [
{
"key": "potato",
"value": true
 },
{
"name": "broccoli",
"value": false
 }
]
}
"standardFromEntriesArguments": {
"uri": "http://surveyUrl.com",
"method": "POST",
"body": "${ {vegetableFeedback : .input.vegetables|from_entries } }"
}
{
...
  "body" : {
    "vegetableFeedback" :  {
      "potato" : true,
     "broccoli" : false
    } 
  }

@csv

This function converts an array to CSV format.

Examples:

Input json Expression in adapter definition document Output json
{
"vegetables": [
{
"veggieName": "potato",
"like": true
 },
{
"veggieName": "broccoli",
"like": false
 }
]
}
{
"arguments": {


"body": "${ .input.vegetables[]|[.veggieName, .like]|@csv  }"

}
}
{

...

  "body" :

"

\"potato\",true
\"broccoli\",false

"

  }

}

@tsv

This function converts an array to tab separated values.

Examples:

Input json Expression in adapter definition document Output json
{
"vegetables": [
{
"veggieName": "potato",
"like": true
 },
{
"veggieName": "broccoli",
"like": false
 }
]
}
{
"arguments": {
"body": "${ .input.vegetables[]|[.veggieName, .like]|@tsv  }"
}
}
{
...
  "body" :
"
potato    true
broccoli    false
"
  }
}

@base64

Examples:

Input json Expression in adapter definition document Output json
{
"username":"a","password":"b"
}
{
"arguments": {
"body": "${ .username + ":"+ .password|@base64 }"
}
}
{

...

  "body" : "YTpi" //(base64 encoded a:b)

}

@base64d

Examples:

Input json Expression in adapter definition document Output json

{ "username":"a","password":"b" }

{ "arguments": { "body": "${ .username + ":"+ .password|@base64|@base64d }" } }

{ ... "body" : "a:b" //(base64 encoded a:b) }