AWS Step function's Jsonpath implementation has some known limitations compared to the original jsonpath implementation:
Reference Paths
A reference path is a path whose syntax is limited in such a way that it can identify only a single node in a JSON structure:
You can access object fields using only dot (.) and square bracket ([ ]) notation.
The operators @ .. , : ? * aren't supported.
Functions such as length() aren't supported.
I'd like request to implement these unsupported features.
Sample use-case:
Cognito User Pools: AdminGetUser
step-function action returns UserAttrubutes
in an array of json nodes:
"UserAttributes": [
{
"Name": "sub",
"Value": "f3cab39d-bfe5-4b1a-a8fc-e1a97ec0d18b"
},
{
"Name": "email_verified",
"Value": "true"
},
{
"Name": "custom:name",
"Value": "My Name"
}
{
"Name": "email",
"Value": "myname@mycompany.com"
}
]
Jsonpath filters would provide a very simple way of extracting data from this payload based on "Name" field of the nodes. For example getting the email for a user:
$.UserAttributes[?(@.Name=='email')].Value
Without this feature I needed to implement a lambda for this purpose, because I can't rely on the order of the response array.
Thank you for your answer. This is exactly what I need. I was trying the filter expression within dataflow-simulator previously, but I failed to produce the result, than I red the ResourcePath limitation, and thought it is global for all AWS json path implementation. But fortunately not. So the real issue with my filter exrpression was about quoting:
$.UserAttributes[?(@.Name=='email')].Value
$.UserAttributes[?(@.Name==email)].Value
In the original jsonpath filter operations string literals must be enclosed by single or double quotes. In AWS you can't use quotes. This is a bit confusing, and would be nice to have highlighted in the AWS documentations.