RulesEngine icon indicating copy to clipboard operation
RulesEngine copied to clipboard

System.Text.Json migration not working as expected

Open diogo-pinho-cko opened this issue 9 months ago • 2 comments

Hi,

I would like to get some insight of the System.Text.Json migration move if possible.

Context

As far as I can tell, the following change (introduced by https://github.com/microsoft/RulesEngine/pull/599) introduced unexpected/incorrect behaviour.

The sample application does not work as expected, as in the behaviour is not the same as it was before when leveraging Newtonsoft.Json. Rules cannot be used over the generated ExpandoObject.

The engine, based on the latest commit on main b1264a2f64c56d4c22995ef3aa44ca8120832283, produces the following result (based on one of the multiple rules, but it's similar for all of them) https://github.com/microsoft/RulesEngine/blob/b1264a2f64c56d4c22995ef3aa44ca8120832283/demo/DemoApp/JSONDemo.cs#L48)

Exception while parsing expression `input1.country == "india" AND input1.loyaltyFactor <= 2 AND input1.totalPurchasesToDate >= 5000 AND input2.totalOrders > 2 AND input3.noOfVisitsPerMonth > 2` - The binary operator Equal is not defined for the types 'System.Text.Json.JsonElement' and 'System.String'.

Is it possible to revert the following change? This makes it impossible to use the library over arbitrary JSON inputs.

diogo-pinho-cko avatar Apr 09 '25 12:04 diogo-pinho-cko

@diogo-pinho-cko - will look into the issue and update the thread.

pbhal avatar Jun 02 '25 23:06 pbhal

@diogo-pinho-cko i have solved this issue in my fork, please refer to it for the solution.

asulwer avatar Jul 09 '25 16:07 asulwer