I have a requirement to convert rules present in json format in database to code in Java at runtime.
For example,
{
"id": "g-KqVJwrEMUYNOEVEnNxxqc",
"rules": [
{
"id": "r-2VC4YQOkYu-lxkGgMABRc",
"field": "firstName",
"value": "Steve",
"operator": "="
},
{
"id": "r-B2Dd6eHO1rsZ-t1mfPk33",
"field": "lastName",
"value": "Vai",
"operator": "="
}
],
"combinator": "and",
"not": false
}
The keys in the json will be known before hand. Also the fields and operator values will be fixed and known.
But I am puzzled as to how to convert something like the one above to code,
inputObject.firstName.equals("Steve") && inputObject.lastName.equals("Vai")
Any leads, thoughts is highly appreciated!