3

Based on the JSON the below I would like to return a list of the enabled account numbers using something like [?enabled == 'true'] with output like [11111, 33333]. Since the account numbers aren't stored in a key value pair is this possible?

{
    "account": {
        "11111": {
            "account-name": "account-1",
            "enabled": "true"
        },
        "22222": {
            "account-name": "account-2",
            "enabled": "false"
            
        },
        "3333": {
            "account-name": "account-3",
            "enabled": "true"
            
        }
    }
}
atg
  • 31
  • 1
  • 1
    Sadly, indeed, the only function that gives you keys will make you lose the content of the objects (e.g. `keys(account)` will give `["3333", "11111", "22222"]`). and there is not much you can do about it since JMESPath do not allow you to request the key of the parent object although accessing the parent object is an often requested feature: https://github.com/jmespath/jmespath.js/issues/22 – β.εηοιτ.βε Jul 08 '21 at 15:27
  • I originally tried adding conditions to the keys() function but quickly realized it wasn't supported. Thanks for the info. – atg Jul 08 '21 at 18:57

0 Answers0