concat expression throws NPE when one of the values is null
The evaluator of the cat function applies toString() to all arguments at line 30 of io.github.jamsesso.jsonlogic.evaluator.expressions.ConcatenateExpression
Object::toString
The expression below evaluates to the arguments {"E001", null}
the evaluation of this expression throws a NPE.
{"cat": ["E001:", {"var": "fieldA"}]}
I expect that the expression {"cat": ["E001:", null]} evaluates to "E001"
Hi @jamsesso I got some code which solves this issue. How can I offer this code to the project ?
@Override public Object evaluate(List arguments, Object data) throws JsonLogicEvaluationException { StringBuilder sb = new StringBuilder(); for (Object arg : arguments) { if (arg == null) continue; if (arg instanceof Number && ((Number) arg).intValue() == ((Number) arg).doubleValue()) { sb.append(((Number) arg).intValue()); } else { sb.append(arg); } } return sb.toString(); }
@hpragt Thanks for the offer to contribute! You can "fork" this repository and make your changes - then open a pull request from your fork to this repository. I can review the code and merge it in.