Парсинг Json - C# (184398)
Формулировка задачи:
Доброго времени суток. Нужен парсер для Json ответов от сервера. В интернете я нашёл такую вещь как Newtonsoft, HO. Данные с сервера приходят, ммм хаотично. То есть класс какой либо под эти данные написать очень не просто, или же можно ,думаю, написать класс, но перед парсингом, саму строку с ответом нужно разделить.
d59f3802b72399959e14198f701e66e7{"sec":"a8f7358d802924d2ee98as2a39be43e3","maps":[{"uid":"705415","map":"1","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"1","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"2","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"2","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"2","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"2","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"3","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"4","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"5","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"5","war":"8","lev":"3"},{"uid":"705415","map":"6","land":"6","war":"1","lev":"3"},{"uid":"705415","map":"6","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"6","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"7","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"6","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"7","war":"0","lev":"3"},{"uid":"705415","map":"8","land":"8","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"2","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"3","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"9","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"9","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"9","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"1","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"4","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"5","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"10","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"1","war":"0","lev":"2"},{"uid":"705415","map":"11","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"4","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"5","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"11","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"1","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"4","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"5","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"12","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"1","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"4","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"5","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"13","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"1","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"4","war":"0","lev":"3"},{"uid":"705415","map":"14","land":"5","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"14","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"1","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"2","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"3","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"4","war":"1","lev":"1"},{"uid":"705415","map":"15","land":"5","war":"0","lev":"3"},{"uid":"705415","map":"15","land":"6","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"7","war":"0","lev":"1"},{"uid":"705415","map":"15","land":"8","war":"0","lev":"1"},{"uid":"705415","map":"16","land":"1","war":"0","lev":"3"},{"uid":"705415","map":"16","land":"2","war":"0","lev":"3"}],"lands":[{"uid":"705415","map":"2","land":"8","stars":"4","countLeft":"0"},{"uid":"705415","map":"3","land":"6","stars":"0","countLeft":"24"},{"uid":"705415","map":"3","land":"8","stars":"2","countLeft":"18"},{"uid":"705415","map":"4","land":"4","stars":"2","countLeft":"0"},{"uid":"705415","map":"6","land":"1","stars":"0","countLeft":"24"},{"uid":"705415","map":"6","land":"5","stars":"0","countLeft":"12"},{"uid":"705415","map":"6","land":"8","stars":"0","countLeft":"24"},{"uid":"705415","map":"7","land":"4","stars":"0","countLeft":"24"},{"uid":"705415","map":"7","land":"5","stars":"0","countLeft":"24"},{"uid":"705415","map":"8","land":"1","stars":"0","countLeft":"18"},{"uid":"705415","map":"9","land":"3","stars":"0","countLeft":"22"},{"uid":"705415","map":"14","land":"4","stars":"1","countLeft":"0"},{"uid":"705415","map":"15","land":"5","stars":"5","countLeft":"0"},{"uid":"705415","map":"16","land":"1","stars":"0","countLeft":"11"},{"uid":"705415","map":"16","land":"2","stars":"5","countLeft":"0"}],"units":[{"id":"531863909","uid":"705415","code":"189","up":"33","expTotal":"30155858","band":"1","critExpTotal":"0"},{"id":"531863915","uid":"705415","code":"190","up":"24","expTotal":"867342","band":"0","critExpTotal":"0"},{"id":"533742065","uid":"705415","code":"188","up":"24","expTotal":"939430","band":"0","critExpTotal":"0"},{"id":"533850697","uid":"705415","code":"187","up":"32","expTotal":"9231191","band":"1","critExpTotal":"0"},{"id":"533913199","uid":"705415","code":"213","up":"23","expTotal":"0","band":"0","critExpTotal":"0"},{"id":"534569875","uid":"705415","code":"213","up":"32","expTotal":"9241541","band":"1","critExpTotal":"0"},{"id":"537518205","uid":"705415","code":"190","up":"33","expTotal":"30187880","band":"1","critExpTotal":"0"},{"id":"538007237","uid":"705415","code":"188","up":"33","expTotal":"30155858","band":"1","critExpTotal":"0"}],"items":[{"id":"28386813","uid":"705415","code":"0","count":"1"},{"id":"1102259","uid":"705415","code":"1","count":"0"},{"id":"1102307","uid":"705415","code":"2","count":"0"},{"id":"28677331","uid":"705415","code":"3","count":"0"},{"id":"28536457","uid":"705415","code":"4","count":"0"},{"id":"28490679","uid":"705415","code":"23","count":"0"},{"id":"30121581","uid":"705415","code":"35","count":"51"},{"id":"29532821","uid":"705415","code":"63","count":"0"},{"id":"29041519","uid":"705415","code":"73","count":"2"},{"id":"28387047","uid":"705415","code":"74","count":"0"},{"id":"29282527","uid":"705415","code":"92","count":"8"},{"id":"28386861","uid":"705415","code":"96","count":"1122"},{"id":"28404435","uid":"705415","code":"97","count":"394"},{"id":"28386815","uid":"705415","code":"98","count":"160"},{"id":"28423591","uid":"705415","code":"99","count":"1"},{"id":"28386941","uid":"705415","code":"100","count":"609"},{"id":"28386847","uid":"705415","code":"101","count":"104"},{"id":"28387517","uid":"705415","code":"202","count":"760748"},{"id":"28386857","uid":"705415","code":"206","count":"213278"},{"id":"28490665","uid":"705415","code":"208","count":"1600"},{"id":"28451987","uid":"705415","code":"212","count":"0"},{"id":"29099589","uid":"705415","code":"214","count":"52"},{"id":"29902227","uid":"705415","code":"215","count":"64"},{"id":"30408517","uid":"705415","code":"217","count":"200"},{"id":"28386859","uid":"705415","code":"300","count":"1215930"},{"id":"28402201","uid":"705415","code":"301","count":"834962"},{"id":"28516995","uid":"705415","code":"401","count":"0"},{"id":"30036877","uid":"705415","code":"403","count":"0"},{"id":"30036875","uid":"705415","code":"404","count":"0"},{"id":"28652957","uid":"705415","code":"410","count":"0"},{"id":"28659631","uid":"705415","code":"411","count":"0"},{"id":"29501951","uid":"705415","code":"412","count":"0"},{"id":"30367397","uid":"705415","code":"413","count":"0"},{"id":"29532639","uid":"705415","code":"463","count":"0"},{"id":"28830713","uid":"705415","code":"621","count":"0"},{"id":"28830591","uid":"705415","code":"1621","count":"0"},{"id":"29849125","uid":"705415","code":"5001","count":"5"},{"id":"29858247","uid":"705415","code":"5002","count":"5"},{"id":"30211229","uid":"705415","code":"5003","count":"5"},{"id":"30582829","uid":"705415","code":"5004","count":"5"},{"id":"31275749","uid":"705415","code":"5204","count":"1"}],"mysql_error":"","dailyBonus":{"uid":"705415","lastDate":"2016-06-30","days":"1","power":"5819574","getDay":"1"},"settings":false,"vip":{"cost":{"id":"203","count":0,"price":25,"bonuses":0,"icon":"http:\/\/mira-play.com\/fantasy\/vip32.png","about":"VIP-status","itemId":"0","discountOnly":"0"},"enabled":1,"gold":325,"goldContinue":500,"goldNonContinue":0,"id":3,"maxCount":0,"powerMax":6000000,"powerMin":2500000,"pvpEnergySpeedUpPercent":15,"showContinueWarningTimeout":604800,"summonBestUnitPossibilityPercent":70,"time":2592000,"toTime":0,"payTime":"1462296133","Pers":{"gold":"613"}},"unitopenings":{"ao":1,"uo":[]},"boss":{"mapBoss":[{"uid":"705415","bossID":"1","wars":"10","pDamage":"1.515","trophy":"91","lastRewardID":"0"},{"uid":"705415","bossID":"2","wars":"10","pDamage":"1.13625","trophy":"119","lastRewardID":"0"},{"uid":"705415","bossID":"3","wars":"2","pDamage":"0.3074","trophy":"45","lastRewardID":"0"},{"uid":"705415","bossID":"4","wars":"18","pDamage":"0.471599","trophy":"13","lastRewardID":"0"},{"uid":"705415","bossID":"6","wars":"5","pDamage":"100","trophy":"270","lastRewardID":"0"},{"uid":"705415","bossID":"7","wars":"3","pDamage":"12.7576","trophy":"84","lastRewardID":"0"},{"uid":"705415","bossID":"8","wars":"8","pDamage":"25.2727","trophy":"417","lastRewardID":"0"},{"uid":"705415","bossID":"10","wars":"9","pDamage":"0.00120854","trophy":"0","lastRewardID":"0"},{"uid":"705415","bossID":"12","wars":"0","pDamage":"0.0538","trophy":"8","lastRewardID":"0"},{"uid":"705415","bossID":"13","wars":"11","pDamage":"0.0286444","trophy":"4","lastRewardID":"0"},{"uid":"705415","bossID":"14","wars":"7","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"16","wars":"5","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"18","wars":"5","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"19","wars":"0","pDamage":"0.0747333","trophy":"8","lastRewardID":"0"},{"uid":"705415","bossID":"20","wars":"0","pDamage":"0.0747333","trophy":"8","lastRewardID":"0"},{"uid":"705415","bossID":"21","wars":"245","pDamage":"1.29333","trophy":"188","lastRewardID":"0"},{"uid":"705415","bossID":"22","wars":"22","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"24","wars":"5","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"25","wars":"10","pDamage":"100","trophy":"14550","lastRewardID":"0"},{"uid":"705415","bossID":"42","wars":"0","pDamage":"0.00903333","trophy":"0","lastRewardID":"0"},{"bossID":"301","level":"24","wars":1}]},"tutorial":["1","2","3","4","6","7","8","19"],"urlCfg":"http:\/\/mira-play.com\/game_fantasy\/cfg\/conf3259.zip","Pers":{"id":"705415","uid":"705415","Name":"VK151098143","Level":"183","Exp":"646","MaxExp":"7407","gold":"613","goldSum":"530","money0":"1800","Energy":20,"MaxEnergy":"20","EnergyTime":1,"daybonus":"2016-06-30","RegDate":"2014-02-28 18:50:18","LastDate":"2016-06-30 19:31:02","SecretCode":"","Ban":null,"levCount":"432","GameOptions":"3","Visits1":"20","fullName":"\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0417\u0430\u0431\u044b\u0448\u043d\u044b\u0439","power":"5819574","pvp_active":"1","timePvpAttacked":"2016-06-30 18:56:18","levPlace":"129437","powPlace":"160065"},"PEFT_TEST_TOTAL":0.092072,"cfgVersion":"0.58","srvTime":1467306735}
Вот такой ответ я получаю, мне нужно пропарсить его, но сериализацией в объект не выходит..Помогите, люди добрые)
Решение задачи: «Парсинг Json»
textual
Листинг программы
JSonResp = func.Post_to_server(Ldata); JSonResp = JSonResp.Substring(JSonResp.IndexOf('{')); character = JsonConvert.DeserializeObject<CharacterData.RootObject>(JSonResp);
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д