Search code examples
apache-cameljq

Function IN/1 does not exist in Spring Boot Apache Camel application


Following the clarification done in:

Using a jq expression, how to return items from a json array using an intermediate mapping array?

I have tried to implement the solution:

[.links[] | select(.from == "product1") | .to] as $colors | [.hits[] | select(.id | IN($colors[])) | .name]

However my application (Spring Boot Apache Camel) gives me this error: "Function IN/1 does not exist".

If I use "in" instead of "IN" I get: "has() is not applicable to STRING".

I am using Apache Camel 4.0.0 (with camel-jq with same version).

How to access this function or replace it by one providing the same result?


Solution

  • Use the equivalent select(IN($colors[]; .id)) or select(any($colors[] == .id; .)) (this is how the filter is defined in builtin.jq)

    Or go with the INDEX-based solution that was also proposed under your original question :)