标签:
public class Person { private string name; public string Name { get { return name; } set { name = value; } } private int age; public int Age { get { return age; } set { age = value; } } }
1)序列化 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Newtonsoft.Json; namespace JSONnet { public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Person person = new Person(); person.Name = "GoldenEasy"; person.Age = 25; string strSerializeJSON = JsonConvert.SerializeObject(person); Response.Write(strSerializeJSON); } } } 输出结果: {"Name":"GoldenEasy","Age":25}
标签:
原文地址:http://www.cnblogs.com/eaysun/p/4236421.html