public class employee
{
private string firstName;
private string lastName;
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
}
public void Page_Load(object sender,EventArgs e)
{
string strJson = "{"firstName":"John","lastName":"Doe"}";
employee em = (employee)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strJson, typeof(employee));
Response.Write("JSON格式的字符串生成对应的类实体:" + em.FirstName + "---" + em.LastName);
Response.Write("<br/><br/>类实体序列化成JSON格式的字符串:" + Newtonsoft.Json.JavaScriptConvert.SerializeObject(em));
}