Can I Use Json Format In CKRule ? 

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. 

This Format is popular with us, and so can i use json format in CKRule ? 

The answer is yes.

CKRule looks like a small IDE, is a scripting environment, you can reference .Net DLLs in the Editor, for example reference .net 4.0's DLL.


Add reference and Using

Add references:  System.Web.Extensions.dll

Add namespace:  System.Web.Script.Serialization

All windows of CKRule can use this namespace after using. The operation is the same as IDE.


Json Serialize and Deserialize

Define business entity in custom types window.

Define Input output variables.

Define temporary variables in CKRule, it’s life cycle is in CKRule.

Json Serialize and Deserialize methods are defined in External calls, just the same as IDE.

From StringàTo Object:

if (string.IsNullOrEmpty(Json)) return;

JavaScriptSerializer js = new JavaScriptSerializer();

object obj = js.Deserialize(Json,typeof(Person));

Info = (Person)obj;

From Objectà To String

JavaScriptSerializer js = new JavaScriptSerializer();

string tmpJson = js.Serialize(Info);

Json = tmpJson;

Business System Settings

Define a BOM Object

    /// <summary>

    /// Json object define

    /// </summary>

    public class JsonEntity


        public string Json { get; set; }


Invoke CKRule’s API(Reference CKRule.dll,using CKRule namespace)

    var _inst = new JsonEntity();

    if (!string.IsNullOrEmpty(rtbResult.Text))


        _inst.Json = rtbResult.Text;


    _inst = new RuleFacade().Exec(RuleName, _inst);

    rtbResult.Text = _inst.Json;




 download demo



Chinese | English Copyright ©2014 CKRule | .Net Rule Engine. All rights reserved.