ietf-wg-jsonpath / draft-ietf-jsonpath-base

Development of a JSONPath internet draft
https://ietf-wg-jsonpath.github.io/draft-ietf-jsonpath-base/
Other
58 stars 20 forks source link

Function composition #336

Closed gregsdennis closed 1 year ago

gregsdennis commented 1 year ago

Tangentially related to #335, would we consider the use of a function as an argument to another function. Currently this is not allowed as a function is not a comparable.

An example for this may be:

$[?max(sqrt(@.foo), @.bar) < 10]

to determine if the maximum between sqrt(@.foo) and @.bar is less than 10.

glyn commented 1 year ago

Yes, I hope to support using the result of a function as an argument to a(nother) function in https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/pull/330.

Note that I don't intend to support passing a function as an argument to a(nother) function or returning a function from a(nother) function, as in the following example, which does both:

$?[foldr(add, 0)(@) > 29]
gregsdennis commented 1 year ago

FWIW I'd be fine with this being in a follow-up PR to #330.

gregsdennis commented 1 year ago

It actually looks like this is already supported.