Importing/Exporting JsonLogic with additional operators
See original GitHub issueFirstly, thank you very much for this library. It’s been a breeze to use!
I’m in the process of replacing react-awesome-query-builder
with this package and have hit my first hitch.
We are using JsonLogic with some additional operators such as:
JSONLogic.add_operation("lessThanOrEqualDate", isBeforeOrEqual);
When attempting to import a query that uses this operator with parseJsonLogic
e.g.
{
"query": {
"and": [
{
"lessThanOrEqualDate": [
{
"var": "device.authenticatedAt"
},
"PT-24H"
]
}
]
}
}
Then passing it into parseJsonLogic
it seems to strip it out. However, any condition that is using one of the defaultOperators
works fine.
I assume it’s something to do with parseJsonLogic
being scoped to the default operators. Is there anyway to let it recognise additional ones?
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Adding Operations (and outside libraries!) - JsonLogic
You can import that library into JsonLogic's list of operators! Note: JsonLogic can't know what's going on inside your custom ... Adding one...
Read more >Additional operators - GitHub
JsonLogic operators cover only the essentials, but there might be a need to provide some extra operators out of the box, to make...
Read more >How to use the json-logic-js.add_operation function in ... - Snyk
To help you get started, we've selected a few json-logic-js.add_operation examples, ... jsonlogic/operators'; // Configure JsonLogic lodashOperators.
Read more >Representing logic as data in JSON - Stack Overflow
I've also written two parsers for it: JsonLogic for JavaScript and JsonLogic for ... I need to add some type conversions and other...
Read more >Blend4Web. User Manual
opening/saving .blend files and importing/exporting scenes and assets. ... Export menu, or type b4w export in the operator search menu ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jakeboone02 Thanks for the help! Will close this issue.
I don’t think you need to use
transformQuery
, just pass a customruleProcessor
toformatQuery
like below (CodeSandbox here):What that’s doing is taking
'<='
property from the result of the default rule processor and assigning it to thelessThanOrEqualDate
property of a new object (unless you’re dealing with a differentfield
, in which case it just falls back to the default rule processor).You may need to add some error checking and other contingencies but hopefully that gets you headed in the right direction.