我正在尝试将此 JSON链接中的数据串起来点击链接查看
使用 JSON.NET。我能够反序列化和字符串整个事情。但我需要的只是以下的值
"Warranty":[
{
"EndDate": "ValueIWant",
"ServiceLevelDescription": "ValueIWant"
},
应该有 4 个保修条目,我需要所有的 EndDate 和 ServiceLevelDescription 并将其列在多行文本框中。
编辑:最终工作代码
string Serial = "G88NJX1";
WebClient client = new WebClient();
Stream stream = client.OpenRead("https://api.dell.com/support/v2/assetinfo/warranty/tags.json?svctags=" + Serial + "&apikey=1adecee8a60444738f280aad1cd87d0e");
StreamReader reader = new StreamReader(stream);
var jObject = JObject.Parse(reader.ReadLine());
foreach (var o in jObject["GetAssetWarrantyResponse"]["GetAssetWarrantyResult"]["Response"]["DellAsset"]["Warranties"]["Warranty"])
{
Console.WriteLine("Warranty end date: {0}", (string)o["EndDate"]);
Console.WriteLine("Warranty service level description: {0}", (string)o["ServiceLevelDescription"]);
}
Console.ReadLine();
stream.Close();