Web.Ajax contains functionality for converting CLI object to and from Json easily.

Consider the following class
public class MyClass
{
    public string String;
    public int Number;
}

To convert to Json
var myObject = new MyClass()
{
    String = "test string",
    Number = 5
};
	
var jsonString = Web.Ajax.Json.ConvertToJson(myObject);

To convert from Json
var jsonString=@"{
	String: 'test string',
	Number: 5
}";
			
var myObject = Web.Ajax.Json.ConvertFrom<MyClass>(jsonString);

Last edited Jan 12, 2013 at 3:12 PM by dpembroke, version 4

Comments

No comments yet.