# JSON functions

# json Convert an object to json

Convert an object to is JSON representation

{{json output['task-id']}}

Example, if the current context is :

{
  "outputs": {
    "task1": {
      "value": 1,
      "text": "awesome1"
    },
    "task2": {
      "value": 2,
      "text": "awesome2"
    }
  }
}

the output of {{ json outputs.task2}} will be {"value":2,"text":"awesome2"}.

# jq Transform vars with JQ

Apply the JQ expression (opens new window) to a variables.

{{jq vars jqExpr [first=false]}}

first mean to always fetch the first element, by default jq return an array of results

WARNING

Internally, Jackson JQ (opens new window) is used and support only a large subset of official JQ.

Example, if the current context is :

{
  "outputs": {
    "task1": {
      "value": 1,
      "text": "awesome1"
    },
    "task2": {
      "value": 2,
      "text": "awesome2"
    }
  }
}
{{jq outputs .task1.value true}}

the output will be 1.