jmespath.site
jmespath.site copied to clipboard
Should it be explained more thoroughly that a a function returns a projection?
Let's say we have a list of list and want to select the sublist where a string starts with a letter.
So, given the JSON
[
[
"ab",
"cd"
],
[
"ef",
"gh"
]
]
One could do:
[?contains([].starts_with(@, `a`), `true`)]
But, in order to have a consistent notation, I was trying to make the contains
function a dot notation too, so:
[?[].starts_with(@, `a`).contains(@, `true`)]
which does not work.
I figured out it as because starts_with
returns a projection, so it can be achieved resetting it:
[?[].starts_with(@, `a`) | contains(@, `true`)]
But I feel, for a new comer that does not know that well about projections and resetting them, it should be explained in the specification in more details, shouldn't it?
Yes, it definitely should be explained better.