Reputation: 558
I'm using a Dynamodb BatchGetItem task in a AWS Step Functions state machine. I need to get the correct values from it's output as those will be used as params in the next task.
My issue is that I need to filter the result on name.S
but when I do that I don't get any result. Does anyone now how to create a JSONPath that will extract the value for the corresponding key.
My Input:
{
"Responses": {
"Table": [
{
"name": {
"S": "Param1"
},
"value": {
"S": "30"
}
},
{
"name": {
"S": "Param2"
},
"value": {
"S": "40"
}
}
]
},
"UnprocessedKeys": {}
}
I expected something like this to work but it didn't. $..Table[?(@.name.S == Param1)].value.S -> 30
.
If I would change the input to this:
{
"Responses": {
"Table": [
{
"name": "Param1",
"value": {
"S": "30"
}
},
{
"name": "Param2",
"value": {
"S": "40"
}
}
]
},
"UnprocessedKeys": {}
}
Then $..Table[?(@.name == Param1)].value.S -> 30
works, but I can't change the structure of the input.
Upvotes: 0
Views: 1499
Reputation: 25669
Map over the Table
items, reshaping each item with a Pass State:
{
"StartAt": "TableItemsMap",
"States": {
"TableItemsMap": {
"Type": "Map",
"ItemsPath": "$.Responses.Table",
"ResultPath": "$.Responses.Table",
"Iterator": {
"StartAt": "ReshapePass",
"States": {
"ReshapePass": {
"Type": "Pass",
"Parameters": {
"name.$": "$.name.S",
"value.$": "$.value"
},
"End": true
}
}
},
"End": true
}
}
}
Upvotes: 1