Here is a sample input JSON with an array and an item to find:
Input :
{
"numbers": [
"1234",
"9999",
"0123",
"2311",
"9911",
"5410"
],
"number": "9999"
}
Output :
{
"numberExists": "true"
}
Both the fields are dynamic and I cannot hard-code anything.
2
Answers
The solution is based on similar post answered by @barbaros Özhan: Jolt Transform – Filter Array Where Fields equal
You might use the following transformation as an alternative to my previous solution which is presented within the other answer :
Another smart, even shorter solution might be
Btw, if returning the else case matters(unlike the the current question’s text), then you might add
to the end of these transformations as presented in the other answer as well.