j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.86k stars 1.05k forks source link

JavaScript Library to parse rules in human readable format #338

Open vikas8352 opened 3 years ago

vikas8352 commented 3 years ago

Hi We have used SpELRuleFactory to load rules from Json. Our requirement is :

  1. Show all rules to users in our web ui.
  2. Business users and update rule directly from web ui and convert the update to Json format.

How can we achieve this ?

zhhaojie commented 3 years ago

Hi, in my company, I stored rules data (JSON) on MySQL (mongo is ok too) and cached them to Redis or LocalJVM cache.

ammmze commented 3 years ago

We're doing that at my company. It may not be a perfect match, but we are using jsep. Here's the proof of concept I did on parsing it out. Make sure you scroll to the bottom, there's a little proof of concept for constructing the expression from the ui. Note: It's using React as we are heavily invested React. But between the jsep library and the stringify function I have in the expressions.js file that should give you the ability to parse out an expression to predictable structure that you can use to render what you need and then you need to be able to produce a similar structure to stringify it back to an expression string.