Waqar Ahmed
Waqar Ahmed

Reputation: 1

Is there a way in JMESPath to remove null keys from data when query is run?

I am working with JSON data and using JMESPath to query and transform this data. I have a scenario where I need to remove keys with null values from my JSON objects dynamically. Here is an example of my input data:

{
  "name": "John",
  "age": null,
  "email": "[email protected]",
  "phone": null
}

I want to transform this data to exclude any key-value pairs where the value is null, resulting in:

{
  "name": "John",
  "email": "[email protected]"
}

The problem is that I am bound to use only JMESPath query to remove null keys. Is there a way to achieve this?

Upvotes: 0

Views: 123

Answers (0)

Related Questions