将对象序列化成json数据
首先 声明一个class
public class JsonSerialize
{
private int _cid;
private string _country; private string _delflag;
public int Cid
{
get { return _cid; }
set { _cid = value; }
} public string Country
{
get { return _country; }
set { _country = value; }
} public string DelFlag
{
get { return _delflag; }
set { _delflag = value; }
} }
然后 将对象实例序列化json数据
List<JsonSerialize> curr = new List<JsonSerialize>();
JsonSerialize o = new JsonSerialize();
o.Cid = 2;
o.Country = "china";
o.DelFlag = "111";
curr.Add(o);
StringBuilder jasonText = new StringBuilder(JavaScriptConvert.SerializeObject(curr));
Response.Write(jasonText.ToString());
以上是一个简单实例,json方面我还会继续研究。。不是很了解。。