Reputation: 122
I have the following input:
{
"Context": {
"fragments": [
[
{
"variableId": "foo",
"value": "121-121-121"
},
{
"variableId": "bar",
"value": "NOT_PROVIDED"
},
{
"variableId": "baz",
"value": "NOT_PROVIDED"
},
{
"variableId": "qux",
"value": 39
}
],
[
{
"variableId": "quux",
"value": {}
}
],
[
{
"variableId": "corge",
"value": 3000
},
{
"variableId": "grault",
"value": []
},
{
"variableId": "garply",
"value": "0"
}
]
]
}
}
Notice how "value"
can be a string, an integer, an array
I would like to filter the input to keep only the values that are not equal to "NOT_PROVIDED"
in a Pass state.
I tried the following expression on https://jsonpath.com/ which works:
$.Context.fragments[*][?(@.value != "NOT_PROVIDED")]
But fails with the following error on StepFunction with the following in a Parameter:
{
"payload.$": "$.Context.fragments[*][?(@.value != \"NOT_PROVIDED\")]"
}
An error occurred while executing the state 'Merge fragments in a single payload' (entered at the event id #46). Invalid comparison between different data types: $.Context.fragments[*][?(@.value != "NOT_PROVIDED")]
Can you please help me find a Json path expression that works in StepFunction, so that the output is:
{
"payload":
[
{
"variableId": "foo",
"value": "121-121-121"
},
{
"variableId": "qux",
"value": 39
},
{
"variableId": "quux",
"value": {}
},
{
"variableId": "corge",
"value": 3000
},
{
"variableId": "grault",
"value": []
},
{
"variableId": "garply",
"value": "0"
}
]
}
I tried the following expression on https://jsonpath.com/ which works:
$.Context.fragments[*][?(@.value != "NOT_PROVIDED")]
But fails with the following error on StepFunction with the following in a Parameter:
{
"payload.$": "$.Context.fragments[*][?(@.value != \"NOT_PROVIDED\")]"
}
Upvotes: 1
Views: 141