把一个集合自定转成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);
标签:city,自定,listData,CityName,json,转成,javaScriptSerializer,new,JavaScriptSerializer 来源: https://www.cnblogs.com/jiangyunfeng/p/10784314.html