"If" expression can support multiple statement within { } block #2265
wutichai-woody
started this conversation in
General
Replies: 1 comment 3 replies
-
Hey @wutichai-woody I'm really struggling to understand what you're asking. Would you mind formatting your code properly and giving a clear example that I can run with exact input and output? Otherwise, not sure how to help you except maybe point out pattern matching. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm using benthos since v3. Can mapping in v4 to support If expression with multiple statement within blacket block?
Ex.
{
"data_list": [
...
...
...
]
}
let var1 = root.data_list
root.result = if this.data.exists('code') {
root.field1 = "x"
root.field2 = "y"
root.field3 = this.data_list or $var1
} else {
root.field1 = "a"
root.field2 = "b"
}
// result
when true
{
"result": {
"field1": "x",
"field2": "y",
"field3": [
...
...
...
]
}
}
when false
{
"result": {
"field1": "a",
"field2": "b",
}
}
Beta Was this translation helpful? Give feedback.
All reactions