.NET 4.x Json десериализация - C#
Формулировка задачи:
помогите десириализовать json туплю не имоверно но не понимаю как это работает
вот пример входной строки
{ "list": [ { "photo": { "id": 3868245, "url": "/photo/3868245", "subject": "chii", "sq150_url": "http://image02.worldcosplay.net/uploads/sq150/31047/kvdsoxmlwiefrowoyjrweblyezhihmkwdaohpakj-3000.jpg", "sq300_url": "http://image02.worldcosplay.net/uploads/sq300/31047/kvdsoxmlwiefrowoyjrweblyezhihmkwdaohpakj-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3868235, "url": "/photo/3868235", "subject": "Jem", "sq150_url": "http://image02.worldcosplay.net/uploads/sq150/31047/yndvmraohwuvebbanxjegoblrrdvoirwfjpmljdm-3000.jpg", "sq300_url": "http://image02.worldcosplay.net/uploads/sq300/31047/yndvmraohwuvebbanxjegoblrrdvoirwfjpmljdm-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3868158, "url": "/photo/3868158", "subject": "junko enoshima yukata", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/oepwguizadfcqykjlvvwrbnziaqcovweshtgjmlg-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/oepwguizadfcqykjlvvwrbnziaqcovweshtgjmlg-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3868097, "url": "/photo/3868097", "subject": "sweet lolita", "sq150_url": "http://image02.worldcosplay.net/uploads/sq150/31047/vizfjmpzakddidrstqjswxkaiyqdhhkxkmwzfyzr-3000.jpg", "sq300_url": "http://image02.worldcosplay.net/uploads/sq300/31047/vizfjmpzakddidrstqjswxkaiyqdhhkxkmwzfyzr-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3868042, "url": "/photo/3868042", "subject": "arachne", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/rsluwmvzqizoolxmbyjoqexkxksckldazkalockr-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/rsluwmvzqizoolxmbyjoqexkxksckldazkalockr-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3867986, "url": "/photo/3867986", "subject": "luka megurine ", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/mdkodmeyyhpycsuxlxgifiigznkkzhgurtcdkgds-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/mdkodmeyyhpycsuxlxgifiigznkkzhgurtcdkgds-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3867890, "url": "/photo/3867890", "subject": "luka megurine ", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/djryctrkjvyyeqmoiyofynolvwhkjnqddkyftvmx-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/djryctrkjvyyeqmoiyofynolvwhkjnqddkyftvmx-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866656, "url": "/photo/3866656", "subject": "steampunk ", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/ghiibmreatfvjvkioclnlwsrgqgrojeggfmmirqr-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/ghiibmreatfvjvkioclnlwsrgqgrojeggfmmirqr-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866620, "url": "/photo/3866620", "subject": "nana", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/jpwadoakdwtoyoosidladbcgrbvpziborideozvn-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/jpwadoakdwtoyoosidladbcgrbvpziborideozvn-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866586, "url": "/photo/3866586", "subject": "hello kitty", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/wghvqwvodzlldhpljprbmsnighxwhotzsbomohgj-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/wghvqwvodzlldhpljprbmsnighxwhotzsbomohgj-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866571, "url": "/photo/3866571", "subject": "luki", "sq150_url": "http://image02.worldcosplay.net/uploads/sq150/31047/iucbtkdhasijpwpaijdbnjcjqzjgyvtxxvoclvas-3000.jpg", "sq300_url": "http://image02.worldcosplay.net/uploads/sq300/31047/iucbtkdhasijpwpaijdbnjcjqzjgyvtxxvoclvas-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866548, "url": "/photo/3866548", "subject": "asuka", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/sxogffyvidhtdatgewsipvcpyxevacmaaixjfgow-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/sxogffyvidhtdatgewsipvcpyxevacmaaixjfgow-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3866114, "url": "/photo/3866114", "subject": "stocking ", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/zdphvhnhznfcwdzgcqklczswiojfyfomeozmxkvh-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/zdphvhnhznfcwdzgcqklczswiojfyfomeozmxkvh-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3865932, "url": "/photo/3865932", "subject": "boa", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/klcitcxmqscibnotdbjolhavlpfmitpxlfybszwb-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/klcitcxmqscibnotdbjolhavlpfmitpxlfybszwb-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3865784, "url": "/photo/3865784", "subject": "s sailor chibiusa S S moon", "sq150_url": "http://image01.worldcosplay.net/uploads/sq150/31047/kdrhkgotxkljcerbqaaqelximsxjgfdobbmaqcez-3000.jpg", "sq300_url": "http://image01.worldcosplay.net/uploads/sq300/31047/kdrhkgotxkljcerbqaaqelximsxjgfdobbmaqcez-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } }, { "photo": { "id": 3865707, "url": "/photo/3865707", "subject": "madoka kaname", "sq150_url": "http://image02.worldcosplay.net/uploads/sq150/31047/xfquqdmftpnzwvukqnvatyybunmeejloeuolpeei-3000.jpg", "sq300_url": "http://image02.worldcosplay.net/uploads/sq300/31047/xfquqdmftpnzwvukqnvatyybunmeejloeuolpeei-3000.jpg", "does_like": false, "is_owner": false, "viewable": true } } ], "pager": { "previous_page": 1, "current_page": 2, "next_page": 3 }, "has_error": 0 }
Решение задачи: «.NET 4.x Json десериализация»
textual
Листинг программы
using System; using System.IO; using System.Linq; using System.Web.Script.Serialization; internal sealed class Program { static void Main() { String json = File.ReadAllText(@"C:\source.json"); var des = new JavaScriptSerializer().Deserialize<dynamic>(json); Console.WriteLine(des["list"][0]["photo"]["url"]); } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д