0
我想從web api獲取項目的集合。將項目組添加到列表
var sampleDataGroups = new List<SampleDataGroup>();
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
// CL: Parse 1 Product from the content
var product = JsonConvert.DeserializeObject<dynamic>(content);
foreach (var data in product)
{
var dataGroup = new SampleDataGroup
(
(string)product.Id.ToString(),
(string)product.Name,
(string)"",
(string)product.PhotoUrl,
(string)product.Description
);
sampleDataGroups.Add(dataGroup);
}
}
我試圖用這個每增加返回到SampleDataGroup列表中的每個產品信息。以便我可以查看該列表中返回的所有產品的列表。
這是產品列表我試圖從網上API
public IEnumerable<Product> GetAllProducts()
{
return products;
}
回報,但我得到一個異常錯誤。
如何編寫/添加返回到SampleDataGroups List的每個產品?
什麼是例外? – Cyral
'Newtonsoft.Json.Linq.JArray'不包含'Id''的定義 – Tester