所以我即將做一個HttpWebRequest
它返回一個jsonstring。反序列化的字符串看起來是這樣的:閱讀json字符串的內容
{
"have_warnings": "20",
"pp_active": false,
"noofslots": 2,
"paused": true,
"pause_int": "0",
"mbleft": 7071.03378,
"diskspace2": 55.610168,
"diskspace1": 55.610168,
"jobs": [{
"timeleft": "0:00:00",
"mb": 6918.785553,
"msgid": "",
"filename": "xxxx",
"mbleft": 5869.015694,
"id": "xx"
},
{
"timeleft": "0:00:00",
"mb": 2238.526516,
"msgid": "",
"filename": "xxxx",
"mbleft": 1202.018086,
"id": "xxxx"
}],
"speed": "0 ",
"timeleft": "0:00:00",
"mb": 9157.312069,
"state": "Paused",
"loadavg": "0.11 | 0.08 | 0.08 | V=444M R=88M",
"kbpersec": 0.0
}
現在我想在我的UI中的標籤顯示的一些數據。什麼是最好的方法來做到這一點?
我tryed:
dynamic array = JsonConvert.DeserializeObject(qstatusOutput);
foreach (var item in array)
{
MessageBox.Show("{0}{1}", item.timeleft, item.mbleft);
}
但我得到一個錯誤
'Newtonsoft.Json.Linq.JProperty' 不包含一個定義 '的timeleft'
+1謝謝你的網站。 – Nasreddine
啊,有我的錯誤..現在它的工作:)真棒網站btw! 謝謝! –