0
[
  {
    "key": 111,
    "Students_Info": [{
      "recordId": 111
    }],
    "Adress_Info": {
      "position": 1,
      "city": null
    }
  },
  {
    "key": 222,
    "Students_Info": [{
      "recordId": 222
    }],
    "Adress_Info": {
      "position": 2,
      "city": "Delhi"
    }
  }
]

How do I filter the null values and remove them from the JSON using JMESPath query?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
coder
  • 13,002
  • 31
  • 112
  • 214

1 Answers1

0

IF you want to filter out the objects having empty Adress_Info.city, you can use a filter projection.

The query:

[?Adress_Info.city]

On the given input would yield:

[
  {
    "key": 222,
    "Students_Info": [
      {
        "recordId": 222
      }
    ],
    "Adress_Info": {
      "position": 2,
      "city": "Delhi"
    }
  }
]
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • Its a huge array and this is one of it. I need to remove globally from all the objects with different keys. So individual filter isn not a good option in this case – coder May 06 '23 at 12:03