0

I have a JSON Array which contains multiple JSON objects:

[
   {
      "s3_uri":"s3://fake-s3-bucket/fact_table/fact_table.csv",
      "dataset":"fact_table"
   },
   {
      "s3_uri":"s3://fake-s3-bucket/dimension_table/dimension_table.csv",
      "dataset":"dimension_table"
   }
]

I would like to filter the JSON using a JSONPath Expression based on the "dataset" key value of "dimension_table" and return all the objects in the array which match this search criteria.

This is the desired filter result.

[
   {
      "s3_uri":"s3://fake-s3-bucket/dimension_table/dimension_table.csv",
      "dataset":"dimension_table"
   }
]

I have attempted to use a filter $[*][?(@.dataset==dimension table)] but this does not maintain the structure of the object and we lose the keys of the object:

[
  "s3://fake-s3-bucket/dimension_table/dimension_table.csv",
  "dimension_table"
]

Is this possible to achieve with a JSONPath Expression?

1 Answer 1

1

The following works on https://jsonpath.com:

$[?(@.dataset=='dimension_table')] 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.