using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Script.Serialization;
public void Test()
{
string jsonArray = "[{ID:'01',Name:'xx1'},{ID:'02',Name:'xx2'},{ID:'03',Name:'xx3'},{ID:'04',Name:'xx4'}]";
JavaScriptSerializer json = new JavaScriptSerializer();
//Json字符串转成对象
List<User> list = json.Deserialize<List<User>>(jsonArray);
//对象转成Json字符串
string strJson = json.Serialize(list);
//Json字符串转成对象
List<User> list2 = json.Deserialize<List<User>>(strJson);
}
[Serializable]
public class User
{
public int ID { get; set; }
public string Name { get; set; }
public string Sex { get; set; }
}