deinspanjer / json-logic-java

An implementation of the json-logic rule parser using Kotlin and the Nashorn ScriptEngine
MIT License
3 stars 2 forks source link

Getting "False" result only #1

Open jaytriv opened 7 years ago

jaytriv commented 7 years ago

JsonObject dataJson = gson.fromJson("{\"appVersion\":2}", JsonObject.class); Object apply = JavaJsonLogic.INSTANCE.apply("{\">\":[{\"var\":\"appVersion\"},1]}", dataJson); System.out.println(apply);

I am getting false result but as per JsonLogic it must return true.

jaytriv commented 7 years ago

And getting following exception when I try to use logic json as JsonElement/JsonObject JsonObject logicJson = gson.fromJson("{\">\":[{\"var\":\"appVersion\"},1]}", JsonObject.class); JsonObject dataJson = gson.fromJson("{\"appVersion\":2}", JsonObject.class); Object apply = JavaJsonLogic.INSTANCE.apply(logicJson, dataJson);

Exception : Exception in thread "main" src/main/resources/logic.js:191 TypeError: com.jsonlogic.JSObjectJsonObjectWrapper@73ee04c8 is not an Object at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:58) at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:214) at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:186) at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:173) at jdk.nashorn.internal.objects.NativeObject.notAnObject(NativeObject.java:135) at jdk.nashorn.internal.objects.NativeObject.keys(NativeObject.java:441) at jdk.nashorn.internal.scripts.Script$\^eval\_.L:14$L:190(src/main/resources/logic.js:191) at jdk.nashorn.internal.scripts.Script$\^eval\_.L:14$L:198(src/main/resources/logic.js:212) at com.jsonlogic.JavaJsonLogic$JsonLogic$$NashornJavaAdapter.apply(Unknown Source) at com.jsonlogic.JavaJsonLogic.apply(JavaJsonLogic.kt:38)