How reference AWS step function parallel task output?

use*_*699 4 jsonpath amazon-web-services aws-lambda aws-step-functions

I have a parallel task in the step function that contains two branches. The input was:

{
  "database": "test",
  "userName": "tester",
  "userID": "test123",
  "adGroup": "testADGroup",
  "dbGroup": "ReadGroup"
}
Run Code Online (Sandbox Code Playgroud)

Each branch return a json result like the following

Branch 1 (I used "OutputPath": "$"):

{
  "requestType": "GrantAccess",
  "DBUser": "exists",
  "ADUser": "exists"
}
Run Code Online (Sandbox Code Playgroud)

Branch 2 (I used "ResultPath": "$.approvalStatus"):

{
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
}
Run Code Online (Sandbox Code Playgroud)

When both the branches complete, the output of the parallel task return:

[
  {
      "requestType": "GrantAccess",
      "DBUser": "exists",
      "ADUser": "exists"
  },
  {
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
  }
]
Run Code Online (Sandbox Code Playgroud)

The next task is a choices,

"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]
Run Code Online (Sandbox Code Playgroud)

and it is keep giving me the following error:

"cause": "An error occurred while executing the state 'CheckApprovalStatus' (entered at the event id #16). Invalid path '$.input[1].approvalStatus': The choice state's condition path references an invalid value."
Run Code Online (Sandbox Code Playgroud)

So here are my questions,

1) How should I reference it in the choice task to get the approvalStatus value?

2) Is there are anyway I can make the parallel task return in json format instead of an array?

Thanks in advance

vga*_*tes 5

"$[1].approvalStatus"如果您不想更改 ResultPath,我认为您应该使用类似的方法。