// JSON Encode and Decode // public static LinguisticRule fromJson(string JsonData) { JSONObject LRJSO = new JSONObject(JsonData); LinguisticRule Result = new LinguisticRule( LRJSO.GetField("Value").str, LRJSO.GetField("Rule").str); Result.implicationMethod = FuzzyImplication.TryParse( LRJSO.GetField("Implication").str); Result._operator = FuzzyOperator.TryParse( LRJSO.GetField("Operator").str); return(Result); }
public void T4LinguisticEncode() { testRule = LinguisticRule.fromJson(TestJsonRule); Assert.AreEqual( testRuleValue, testRule.encodeLinguisticJson().GetField("Value").str ); Assert.AreEqual( TestImplication, FuzzyImplication.TryParse( testRule.encodeLinguisticJson(). GetField("Implication").str) ); Assert.AreEqual( FuzzyOperator.nameOf(TestOperator), testRule.encodeLinguisticJson(). GetField("Operator").str ); Assert.AreEqual( testActualRule, testRule.encodeLinguisticJson().GetField("Rule").str ); }