Asp.net Json serialization and asp. netjson serialization
Json is widely used in project development as a data transmission format and standard. So how to generate data in JSON format becomes the first problem we need to solve here we use. net.
First, get data
Public bannerImg (string imageurl, string linkurl)
{
ImageUrl = imageurl;
LinkUrl = linkurl;
}
Public string imageUrl {get; set ;}
Public string linkUrl {get; set ;}
}
Public class bannerImgList
{
Public List <bannerImg> GetProducts {get; set ;}
}
Usage
Dictionary <string, string> d = Bannner. getBanners ();
String localURL = "http://www.roubaowl. com7/Images /";
List <bannerImg> banner = new List <bannerImg> ()
{
New bannerImg (localURL + "1.png"," http://www.baidu.com "),
New bannerImg (localURL + "2.png"," http://www.baidu.com "),
New bannerImg (localURL + "3.png"," http://www.baidu.com ")
};
BannerImgList bannerList = new bannerImgList ();
BannerList. GetProducts = banner;
Response. Write (new JavaScriptSerializer (). Serialize (bannerList ));
// Wait for future check and make it easier for others.
Me: renhanlinbsl@163.com
13:116