Closed tuananh closed 5 years ago
You can implement something like set-temp
JSONLogic.add_operation('set_temp', function(key, value){
if ( ! this.temp_variables){
this.temp_variables = {};
}
this.temp_variables[key] = value;
console.log('temp value', value);
return value;
});
JSONLogic.add_operation('get_temp', function(key){
if ( ! this.temp_variables){
this.temp_variables = {};
}
return this.temp_variables[key];
});
And use get_temp on the next step
eg. I want to have a set of rules and have data running through all of them.
a
== 1 will multiply price by 2b
== 2 will multiply price by 3if i pass data as {a: 1, b: 2, price: 100}, price will be 600.
How can i do this with json-logic?