Skip to content

#match

Matches a value against cases from top to bottom and returns the value of the first one that matches.

"#match(source as @variable) into 'name'": [ { "case": "result" }, ... ]
Category Pattern matchingValid in Property name
Name Type Description
source path | value The value to match.
@variable variable Bound to the value for use in cases.

any

source.json
{
"somePath": [ 1, 2 ]
}
transformer.json
{
"#match($.somePath as @x) into 'result'": [
{ "#is([])": "'Found an empty array'" },
{ "#is([_])": "'Found an array with one or more elements'" },
{ "#default()": "'Found something else'" }
]
}
output.json
{
"result": "Found an array with one or more elements"
}

Try it in the playground →

#is · #given · #default