with
The template command {{with _expression_}} sets the context to the result of expression and executes the enclosed expressions or executes the corresponding {{else}} block if the expression evaluates to null.
Input:
{
"user": {
"name": "alice",
}
}Template:
<template>
{
{{with ./user}}
"Name": {{ name }}
{{else}}
"Name": "unknown"
{{end}}
}
</template>Output:
{
"Name": "alice"
}Example: with and json-doc()
with and json-doc(){{with}} is especially useful in conjunction with json-doc() to consolidate data from multiple sources using more compact expressions.
Input:
Input fit://request/request/body:
Template:
Output:
Last updated
Was this helpful?