I have a dictionary, I want to do a nested jmespath.search on the keys of the dictionary for keys that start with a specific string, but I can only seem to use the @
operator once.
> d = {'foo1': 'bar', 'foo2' : 'baz'} # here's a dummy example
> jmespath.search('keys(@)[?starts_with(@, "foo")]', jmespath.search('@', d)) # in an ideal world, I'd get ['foo1', 'foo2']
> *** jmespath.exceptions.JMESPathTypeError: In function starts_with(), invalid type for value: None, expected one of: ['string'], received: "null"
This is what I actually get, however when I enter the following:
> jmespath.search('keys(@)[?starts_with([@], "foo")]', jmespath.search('@', d)) # in an ideal world, I'd get ['foo1', 'foo2']
I see
> *** jmespath.exceptions.JMESPathTypeError: In function starts_with(), invalid type for value: ['foo1'], expected one of: ['string'], received: "array"
Is there a way of doing this in JMESPath, or am I dreaming? I need the nested bit