1

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?

1 Answer 1

1

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"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.