0
我有解析JSON到C#列表的問題。我使用Json.net來解析json。我的問題是,我得到錯誤「錯誤轉換價值」高「鍵入」。請幫幫我。C#/ WP7 Json.net解析到列表
我的JSON:
{"sold":{"high":40.64625,"low":35.02,"avg":37.929384985,"buy":40.28,"sell":40.3}}
我的代碼:
public class sold
{
public string high { get; set; }
public string low { get; set; }
public string avg { get; set; }
public string buy { get; set; }
public string sell { get; set; }
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
JObject something = JObject.Parse(e.Result);
IList<JToken> results = something["sold"].Children().ToList();
IList<sold> searchResults = new List<sold>();
foreach (JToken result in results)
{
sold searchResult = JsonConvert.DeserializeObject<sold>(result.ToString());
searchResults.Add(searchResult);
}
現在我得到不同的錯誤「Error conversion value」high「to type'My_app.sold'。Path'',line 1,position 6.」你能幫忙嗎? – user1992794 2013-03-05 14:56:30
Try:JsonConvert.DeserializeObject(something [「sold」]。ToString()); –
2013-03-05 15:17:17
現在,它的工作。謝謝 – user1992794 2013-03-06 14:26:39