json-logic-java icon indicating copy to clipboard operation
json-logic-java copied to clipboard

Can't evaluate single text parameter

Open buruczky-viktor opened this issue 8 months ago • 0 comments

Since the TextNode from the jackson library implements the iterable interface the isEligible method of ArrayLike returns true for that type of parameter. This can cause issues if the only parameter of an unary function is a string. In PreEvaluatedArgumentsExpression.evaluate, there is this piece of code:

if (values.size() == 1 && ArrayLike.isEligible(values.get(0))) {
  values = new ArrayLike(values.get(0));
}

This will try to turn any TextNode into an ArrayLike using it's iterator() method. According to the jackson documentation, that will call the elements() method, which in turn returns an empty iterator, so at the end the result will be an empty ArrayLike object.

buruczky-viktor avatar Apr 23 '25 14:04 buruczky-viktor