我想解析使用動態對象的JSON。這裏是圖書館,JSON數據轉換器,我使用:https://github.com/cmcdonaldca/shopify.net解析動態數據
這是我的錯誤信息:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:「串」不 不包含定義'產品'
這裏是我的JSON:
這裏是我的代碼:
public void GetProducts()
{
// The JSON Data Translator will automatically decode the JSON for you
dynamic data = _api.Get("/admin/products.json");
// the dynamic object will have all the fields just like in the API Docs
foreach (var product in data.products)
{
Console.Write(product.title);
}
}
我試圖data.products和數據,但我不能讓裏面的產品對象。
向我們展示這個 「JSON數據轉換器」 的實施。 –
json對象是否有標題屬性? – PCG
我添加了代碼,是的,有一個標題屬性。 –