json-everything: JsonLogic - unexpected result after evaluating rule
Environment
- Nuget Package: JsonLogic
- Nuget Version: 1.3.2
- OS: Windows
- .Net Target: Net5.0
Describe the bug JsonLogic does not produce the same output as jsonlogic.com/play.html Your playground also differs (as it’s using the library) https://json-everything.net/json-logic
To Reproduce Rule:
{
"if": [
{
"var": "data.sub"
},
{
"===": [
{
"var": "data.sub.0.element"
},
"12345"
]
},
true
]
}
Data:
{
"data": {
"sub": [
{
"element": "12345"
}
]
}
}
==> Result is truthy. Adding a different data to the data.sub.0.element field should result in falsy.
Rule:
{
"if": [
{
"var": "data.sub"
},
{
"===": [
{
"var": "data.sub.0.element"
},
"12345"
]
},
true
]
}
Data:
{
"data": {
"sub": [
{
"element": "12346"
}
]
}
}
Shows no result on the playground page (https://json-everything.net/json-logic) and throws an exception in .net code.
Expected behavior Result should be falsy in the second example (in case I’m getting how jsonlogic works, which I’m not sure about). The playground on https://jsonlogic.com/play.html shows the output as false
Thanks
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (14 by maintainers)
Commits related to this issue
- added tests to reproduce #183 — committed to gregsdennis/json-everything by gregsdennis 3 years ago
- added tests to reproduce #183 — committed to gregsdennis/json-everything by gregsdennis 3 years ago
- added tests to reproduce #183 — committed to gregsdennis/json-everything by gregsdennis 3 years ago
- added tests to reproduce #183 — committed to gregsdennis/json-everything by gregsdennis 3 years ago
We got a response from JsonLogic, but upon revisiting it, it seems that my implementation is returning
truenow. I had added aRuleCollectionclass which in essense is an array of rules that is evaluated as a rule. I think this did it.