Reputation: 3941
I am are trying to write a step function where each function.
Let's say this is the output of one of the function is
{
...
"foo": {
"1": "one"
"2": "two",
"5": "five"
},
"current": 2
...
}
I have a choice statement, which needs to check what is the value of test_key
and dereference it in foo
dictionary.
...
"ChoiceState": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.foo['$.current']", <--- This is unsupported
"StringEquals": "two",
"Next": "TwoFunction"
},
{
"Variable": "$.foo['$.current']", <--- This is unsupported
"StringEquals": "three",
"Next": "ThreeFunction"
}
...
],
"Default": "DefaultFunction"
}
...
How do I use dynamic reference in choice states?
Upvotes: 1
Views: 1319
Reputation: 1194
JSONPath doesn't support dynamic keys so this isn't possible. You have to restructure your input data or combine multiple Choice Rules with the And
comparison operator to check the corresponding property based on current
:
{
"And": [
{
"Variable": "$.current",
"StringEquals": "2"
},
{
"Variable": "$.foo.2",
"StringEquals": "two"
}
],
"Next": "TwoFunction"
}
Upvotes: 1