把一个集合自定转成json字符串
List<CityData> listData =new List<CityData>();
//把一个集合自定转成json字符串。
foreach (var city in ctiyTable)
{
listData.Add(new CityData()
{
CityId = city.CityID,
CityName = city.CityName
});
}
System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer =new JavaScriptSerializer();
var response= javaScriptSerializer.Serialize(listData);