C # deserialization of JSON array objects

Source: Internet
Author: User

To deserialize Douban station data:

{"R": 0, "song": [{"picture": "http: \/img1.douban.com \/mpic \/s1417892.jpg", "albumtitle ": "I'm not Huang Rong", "company": "", "rating_avg": 3.19481, "public_time": "2004", "ssid": "0283", "album ": "\/subject \/1408779 \/", "like": "0", "artist": "Wang Rong", "url": "http: \ // mr3.douban.com \/201204261547 \/Users \/view \/song \/small \/p702236133 "," title ":" I am not Huang Rong "," subtype ": "", "length": 217, "sid": "702236", "aid": "1408779" },{ "picture": "http: \ // img1.douban.com \/mpic \/s1413751.jpg "," albumtitle ":" stick to the end "," company ":" "," rating_avg ": 3.45544," public_time ": "2002", "ssid": "ea36", "album": "\/subject \/1404968 \/", "like": "0", "artist ": "Addu", "url": "http: // mr3.douban.com \/201204261547 \/61fd94ed3d09ac99c2adbc79b6f0b1 \/view \/song \/small \/p468095.mp3", "title ": "If you leave you next time", "subtype": "", "length": 263, "sid": "468095", "aid": "1404968 "}, {"picture": "http: \ // img3.douban.com \/mpic \/s3839395.jpg", "albumtitle": "float Year", "company": "", "rating_avg ": 4.52431, "public_time": "2003", "ssid": "6f05", "album": "\/subject \/1408222 \/", "like ": "0", "artist": "Li Jian", "url": "http: \ // mr3.douban.com \/201204261547 \/Users \/view \/song \/small \/p696589133 "," title ":" Violet "," subtype ":"", "length": 276, "sid": "696589", "aid": "1408222" },{ "picture": "http: \ // img1.douban.com \/mpic \/s2974583.jpg "," albumtitle ":" favored "," company ":" "," rating_avg ": 4.33157," public_time ": "1998", "ssid": "c7ed", "album": "\/subject \/1776536 \/", "like": "0", "artist ": "Liu Qin", "url": "http: \ // mr4.douban.com \/201204261547 \/Hangzhou \/view \/song \/small \/p706174.mp3", "title ": "visit", "subtype": "", "length": 254, "sid": "706174", "aid": "1776536" },{ "picture ": "http: \ // img1.douban.com \/mpic \/s1648854.jpg", "albumtitle": "Wuniang", "company": "", "rating_avg": 3.6028, "public_time": "2006", "ssid": "9d7a", "album": "\/subject \/1777567 \/", "like": "0 ", "artist": "Cai Yilin", "url": "http: \/mr3.douban.com \/201204261547 \/Users \/view \/song \/small \/p626537.pdf ", "title": "Wuniang", "subtype": "", "length": 184, "sid": "626537", "aid": "1777567 "}, {"picture": "http: \ // img1.douban.com \/mpic \/s000000002.jpg", "albumtitle": "Greatest Hits", "company ":"", "rating_avg": 4.12889, "public_time": "2004", "ssid": "ada5", "album": "\/subject \/1770175 \/", "like": "0", "artist": "A-Teens", "url": "http: \\// mr3.douban.com \/201204261547 \/ce48ab60ae6071463515f50fb80af9fb \/view \/song \/small \/p580439.pdf "," title ":" Can't Help Falling In Love ", "subtype": "", "length": 185, "sid": "580439", "aid": "1770175" },{ "picture": "http: \ // img1.douban.com \/mpic \/s3440611.jpg "," albumtitle ":" Playing My Game "," company ":" "," rating_avg ": 4.5791," public_time ": "2003", "ssid": "8dea", "album": "\/subject \/3346253 \/", "like": "0", "artist ": "Ene Marlin", "url": "http: \ // mr5.douban.com \/201204261547 \/1211b87f7ee89232b446f6464bcfa978 \/view \/song \/small \/p1516271.mp3 ", "title": "Unforgivable Sinner", "subtype": "", "length": 241, "sid": "1516271", "aid": "3346253 "}, {"picture": "http: \ // img3.douban.com \/mpic \/s1646146.jpg", "albumtitle": "All Good Things", "company ":"", "rating_avg": 4.37042, "public_time": "2004", "ssid": "f6dc", "album": "\/subject \/1401415 \/", "like": "1", "artist": "Sissel", "url": "http: \ // mr3.douban.com \/201204261547 \/Users \/view \/song \/small \/p380437.pdf "," title ":" shocould It Matter "," subtype ": "", "length": 303, "sid": "380437", "aid": "1401415" },{ "picture": "http: \ // img3.douban.com \/mpic \/s3375098.jpg "," albumtitle ":" Christmas in My Hear... "," company ":" "," rating_avg ": 4.42263," public_time ":" 2007 "," ssid ":" 03ba "," album ": "\/subject \/3311456 \/", "like": "0", "artist": "Sarah Connor", "url": "http: \ // mr3.douban.com \/201204261547 \/Users \/view \/song \/small \/p1528887.mp3 "," title ":" Christmas in My Heart "," subtype ": "", "length": 288, "sid": "1528887", "aid": "3311456" },{ "picture": "http: \ // img1.douban.com \/mpic \/s1931453.jpg "," albumtitle ":" The Simpsons: Songs... "," company ":" "," rating_avg ": 4.06341," public_time ":" 2006 "," ssid ":" a51a "," album ": "\/subject \/1928228 \/", "like": "0", "artist": "Danny Elfman \/Alf Clausen", "url": "http: \ // mr4.douban.com \/201204261547 \/Users \/view \/song \/small \/p522272.mp3 "," title ":" Two Dozen And One Greyhounds (", "subtype": "", "length": 121, "sid": "522272", "aid": "1928228"}]}
Error: "should be the" root "element from the namespace ".. If the namespace is "" or "None ". "
Construct the corresponding class when deserializing JSON data using. NET 3.5

Class Songs
{
[DataMember]
Public string r {get; set ;}

[DataMember]
Public playlist [] song {get; set ;}
} Playlist is a class constructed based on the data type of Douban.

Solution: remove '\' from the data.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.