私はこのようなWebサーバーにJSONを持っています:
{"My Book List": [{"ID":"5","TYPE":"History","TITLE":"Ekannoborti","PRICE":"200","IMAGE":"Ekannoborti.jpg","DOWNLOAD LINK":"http://www.starhostbd.com/"}],"success":3}
それを逆シリアル化するために、私はこれまでに行ってきました:
public class Attributes
{
public string ID{ get; set; }
public string TYPE { get; set; }
public string TITLE { get; set; }
public string PRICE { get; set; }
public string IMAGE { get; set; }
public string DOWNLOADLINK { get; set; }
}
public class DataJsonAttributeContainer
{
public List<Attributes> attributes { get; set; }
//public Attributes attributes { get; set; }
}
public static T DeserializeFromJson<T>(string json)
{
T deserializedProduct = JsonConvert.DeserializeObject<T>(json);
return deserializedProduct;
}
&私のコードで:
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
//var deserializedJSON = JsonConvert.DeserializeObject<Attributes>(e.Result);
var container = DeserializeFromJson<DataJsonAttributeContainer>(e.Result);
string asd = container.attributes[0].DOWNLOADLINK[0].ToString();
//string asd = deserializedJSON.DOWNLOADLINK[0].ToString();
}
問題は次のとおりです。デバッグウィンドウから、データがe.Resultに割り当てられていることがわかりますが、コンテナはnullのままです。この問題を解決する方法は?助けてください !