Step functions Filter support for jsonpath - feature request

0

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.

Liszi
asked 2 years ago1833 views
1 Answer
1

Would jsonpath logic applied to "interests" payload in the example below achieve what you are after? https://aws.amazon.com/blogs/compute/using-jsonpath-effectively-in-aws-step-functions/

Adding this blog about the Data Flow Simulator that you might find useful as well for your testing. https://aws.amazon.com/blogs/compute/modeling-workflow-input-output-path-processing-with-data-flow-simulator/

Kishan
answered 2 years ago
  • 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:

    • wrong: $.UserAttributes[?(@.Name=='email')].Value
    • correct: $.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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions