0
嗨,我有以下代碼從一個REST服務數據:Asp.NET HttpClient的定製JsonConverter
HttpResponseMessage response;
response = client.GetAsync("CatalogUpdate/" + sessionId).Result;
if (response.IsSuccessStatusCode)
{
catalogs = response.Content.ReadAsAsync<List<Models.CatalogInfo>>().Result;
}
我CatalogInfo類是:
public class CatalogInfo
{
public CatalogInfo(int id,string name,string date)
{
this.ID = id;
this.Name = name;
this.Date = date;
}
public int ID { get; set; }
public string Name { get; set; }
public string Date { get; set; }
}
並且json,即時通訊從得到REST服務是:
{"error":false,"locations":[{"ID":"3","ABC":"XC","Description":"Rome","Status":"1"},{"ID":"4","CD1":"XH","Description":"Italy","Status":"1"}]}
我想將JSON映射到我的CatalogInfo
類,是有T A方式o這樣做?
你怎麼想*地圖*考慮到他們有不同的屬性,似乎無關? – Lloyd
我想用ID和名稱來映射ID – VAAA
這個[問題] [1]看起來與您正在尋找的相似。 [1]:http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object – Anushree