Output

Required: no Default: body, when iterate is not set; item otherwise

With the output directive you can specify how you want your module output to look. When using iterate, output is processed for each item of the array, that was specified with the iterate directive. When not using iterate, output is executed only once and the result is fed to the wrapper directive, if present, otherwise it will be the final result of the module.

When you aren't using iterate, you can use body object to specify the output of the module.

"output": "{{body}}"

When using iterate directive, you specify the output using the item object. However, the body is still available to use.

"iterate": "{{body.items}}",
"output": {
    "id": "{{item}}"
}

When using the wrapper directive, the value of it is what will become the final output of the module. This directive is executed only once and at the end of the processing chain. There are no more directives or transformations after it.

"iterate": "{{body.users}}",
"output": {
	"label": "{{item.name}}",
	"value": "{{item.id}}"
},
"wrapper": {
	"someAdditionalStuff": "helloworld",
	"aNumber": "{{body.aValue}}",
	"data": "{{output}}"
}

The best approach is to return the API response as it is. You can learn more about best practices on response processing here.

If API returns a JSON string inside a JSON object, you can use parseJSON() function.

Last updated