I'm trying to evaluate expressions with arithematic operators in karate using javascript. As an alternative to javascript eval(), I'm using karate.get() method to perform the evaluations. In All cases, I'm able to evaluate the expression and get a boolean value. But when performing evaluation on JSON object, to check if it null, karate.get is returning first value of the expression instead of a boolean value. Any help would be appreciated. Thanks in advance. Note: I'm facing this issue only when I have added karate-core dependency in my pom.xml.
* json input1 = '{ "id": 4068, "name": "Rep. Draupadi Asan"}'
* def input2 = null
* def operator = "!="
* def Dataiterate =
"""
function(input1, input2,operator){
let stringifiedInput1 = JSON.stringify(input1);
let stringifiedInput2 = JSON.stringify(input2);
let valid = karate.get(stringifiedInput1 + operator + stringifiedInput2)
karate.log(valid)
if(valid)
{
karate.log("true")
}
else
{
karate.log("false")
}
}
"""
* def final = Dataiterate(input1,input2,operator)