Closed iliecirciumaru closed 3 years ago
According to JSONLogic specification following behaviour is expected:
jsonLogic.apply( {"var" : 1 }, [ "apple", "banana", "carrot" ] ); // "banana"
Note that index 1 or "1" should return same result
1
"1"
According to JsonLogicEvaluator.evaluatePartialVariable, I think was planned, that following expression returns null.
JsonLogicEvaluator.evaluatePartialVariable
null
jsonLogic.apply( {"var" : "5" }, [ "apple", "banana", "carrot" ] ); // null
If index asked equals to size of the array, then exception is thrown instead of null return.
jsonLogic.apply( {"var" : "3"}, [ "apple", "banana", "carrot" ] ); // throws IndexOutOfBoundsException
Problem in code JsonLogicEvaluator.evaluatePartialVariable: Current
if (index < 0 || index > list.size()) { return null; }
Should be
if (index < 0 || index >= list.size()) { return null; }
Change in JsonLogicEvaluator: index > list.size ---> index >= list.size
index > list.size
index >= list.size
@iliecirciumaru Version 1.0.6 was deployed with your changes. Thanks for contributing a fix!
Description
According to JSONLogic specification following behaviour is expected:
Note that index
1
or"1"
should return same resultAccording to
JsonLogicEvaluator.evaluatePartialVariable
, I think was planned, that following expression returnsnull
.Problem
If index asked equals to size of the array, then exception is thrown instead of
null
return.Problem in code
JsonLogicEvaluator.evaluatePartialVariable
: CurrentShould be
Solution
Change in JsonLogicEvaluator:
index > list.size
--->index >= list.size