このサンプル コードを使用して、C# で JSON データの親データを取得する方法を誰かが教えてくれますか?
string JSON = JsonConvert.SerializeObject(message["data"]);
//Deserialize to strongly typed class i.e., RootObject
RootObject obj = JsonConvert.DeserializeObject<RootObject>(JSON);
//loop through the list and show on console
foreach (Result resultsItem in obj.results)
{
Console.WriteLine(resultsItem.shipping + "-" + resultsItem.model + "-" + resultsItem.price +
"-" + resultsItem.product_name);
}
ルートオブジェクトクラスは次のようになります
public class Result
{
public string shipping { get; set; }
public string model { get; set; }
public string price { get; set; }
public string item { get; set; }
public string product_name { get; set; }
public string availability { get; set; }
}
public class RootObject
{
public List<object> cookies { get; set; }
public List<Result> results { get; set; }
public string connectorGuid { get; set; }
public string connectorVersionGuid { get; set; }
public string pageUrl { get; set; }
public int offset { get; set; }
}
Result クラスに列を表示するコードを書くことはできましたが、rootobject クラスの "PageUrl" に到達する方法がわかりません。foreach ループですべての可能な名前を試しましたが、RootObject の列にアクセスできません。どんな助けでも大歓迎です。ありがとう