Как правильно сделать parser json? - C#
Формулировка задачи:
{
"1": {
"row": {
"last": "1,0930",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"ma_class": "redFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "downArrow",
"summaryLast": "1,0930",
"summaryName": "EUR\/USD",
"summaryNameAlt": "EUR\/USD",
"summaryChange": "-0,0088 (-0,80%)",
"summaryChangeClass": "redFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"technicalSummaryClass": "sell",
"maBuy": 0,
"maSell": 12,
"tiBuy": 0,
"tiSell": 8
},
"1691": {
"row": {
"last": "82,723",
"ma": "\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e",
"ma_class": "neutralFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "upArrow",
"summaryLast": "82,723",
"summaryName": "EUR\/RUB",
"summaryNameAlt": "EUR\/RUB",
"summaryChange": "-0,226 (-0,27%)",
"summaryChangeClass": "redFont",
"technicalSummary": "\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e",
"technicalSummaryClass": "neutral",
"maBuy": 10,
"maSell": 2,
"tiBuy": 3,
"tiSell": 4
},
"2186": {
"row": {
"last": "75,6242",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u041f\u043e\u043a\u0443\u043f\u0430\u0442\u044c",
"ma_class": "greenFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "upArrow",
"summaryLast": "75,6242",
"summaryName": "USD\/RUB",
"summaryNameAlt": "USD\/RUB",
"summaryChange": "+0,2601 (+0,35%)",
"summaryChangeClass": "greenFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u041f\u043e\u043a\u0443\u043f\u0430\u0442\u044c",
"technicalSummaryClass": "buy",
"maBuy": 12,
"maSell": 0,
"tiBuy": 8,
"tiSell": 0
},
"2": {
"row": {
"last": "1,3874",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"ma_class": "redFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "downArrow",
"summaryLast": "1,3874",
"summaryName": "GBP\/USD",
"summaryNameAlt": "GBP\/USD",
"summaryChange": "-0,0089 (-0,64%)",
"summaryChangeClass": "redFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"technicalSummaryClass": "sell",
"maBuy": 0,
"maSell": 12,
"tiBuy": 0,
"tiSell": 9
},
"3": {
"row": {
"last": "113,88",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u041f\u043e\u043a\u0443\u043f\u0430\u0442\u044c",
"ma_class": "greenFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "noneArrow",
"summaryLast": "113,88",
"summaryName": "USD\/JPY",
"summaryNameAlt": "USD\/JPY",
"summaryChange": "+0,90 (+0,80%)",
"summaryChangeClass": "greenFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u041f\u043e\u043a\u0443\u043f\u0430\u0442\u044c",
"technicalSummaryClass": "buy",
"maBuy": 10,
"maSell": 2,
"tiBuy": 10,
"tiSell": 1
},
"9": {
"row": {
"last": "124,47",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"ma_class": "redFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "noneArrow",
"summaryLast": "124,47",
"summaryName": "EUR\/JPY",
"summaryNameAlt": "EUR\/JPY",
"summaryChange": "-0,03 (-0,02%)",
"summaryChangeClass": "redFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"technicalSummaryClass": "sell",
"maBuy": 0,
"maSell": 12,
"tiBuy": 0,
"tiSell": 9
},
"5": {
"row": {
"last": "0,7164",
"ma": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"ma_class": "redFont",
"clock": "<span class="newSiteIconsSprite greenClockIcon"> <\/span>"
},
"arrowBoxClass": "noneArrow",
"summaryLast": "0,7164",
"summaryName": "AUD\/USD",
"summaryNameAlt": "AUD\/USD",
"summaryChange": "-0,0073 (-1,01%)",
"summaryChangeClass": "redFont",
"technicalSummary": "\u0410\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c",
"technicalSummaryClass": "sell",
"maBuy": 0,
"maSell": 12,
"tiBuy": 0,
"tiSell": 10
},
"time": "2016-02-26 15:54:37 GMT"
}JObject obj = JObject.Parse(string);
int m = 0;
foreach (var item in obj["1"])
{
m++;
log((string)item["maBuy"]);
log((string)item["maSell"]);
log((string)item["tiBuy"]);
log((string)item["tiSell"]);
}Решение задачи: «Как правильно сделать parser json?»
textual
Листинг программы
JavaScriptSerializer jss= new JavaScriptSerializer(); YourClass obj = jss.Deserialize<YourClass>(jsonResponse);