I have Json File like below:
{ "Country": "QAT", "Rules": "if(BO.SenderCountryId == 'QAT' && BO.SenderIdExpiryDate < DateTime.Today.AddDays(-90)){true}", "ErrorKey": "BusinessErrExpiryDateInvalid" }
want to run above json Key "Rules" in c# using JINT:
Engine engine = new Engine(); engine.SetValue("BO", BO); foreach (JProperty item in Rule) { if (item.Name.Equals("Rules")) { engine.Execute(Convert.ToString(item.Value)); bool validated = (bool)engine.GetCompletionValue().ToObject(); } }
Getting Error "DateTime is not defined" .It would be helpful If someone can help me to understand can it possible to use DateTime object in JSON using JINT
Asked
Active
Viewed 262 times
0

Bhushan Muttha
- 1
- 2
-
1Isn't JINT a javascript interpreter? If so, it probably doesnt have the System.DateTime class available, which is a .NET class. you could try to make a valid javascript code for jint, for example by trying it out here: https://playcode.io/603110/ – Michael Schönbauer May 13 '20 at 06:40
-
ok thanks, i will try on that. – Bhushan Muttha May 13 '20 at 08:30