【发布时间】:2019-04-18 20:34:51
【问题描述】:
如果我没记错的话,https://status.cloud.google.com/incidents.jsonGoogle 正在使用 Json 数组。我正在使用 Newtonsoft.Json 并使用下面的代码反序列化 json。我是否使用正确的方法来提取 json?
using (var webClient = new WebClient())
{
String rawJSON = webClient.DownloadString("https://status.cloud.google.com/incidents.json");
StatusCollection statusCollection = JsonConvert.DeserializeObject<StatusCollection>(rawJSON);
Console.WriteLine(statusCollection.Statuses.Count);
}
status.cs
namespace StatusJSONv1
{
public class Status
{
string Begin { get; set; }
string Created { get; set; }
string End { get; set; }
string External_desc { get; set; }
string Modified { get; set; }
MRUpdateContainer Most_recent_update { get; set; }
int Number { get; set; }
bool Public { get; set; }
string Service_key { get; set; }
string Service_name { get; set; }
string Severity { get; set; }
List<Update> Updates { get; set; }
string Uri { get; set; }
}
public class MRUpdateContainer
{
string Created { get; set; }
string Modified { get; set; }
string Text { get; set; }
string When { get; set; }
}
public class Update
{
string Created { get; set; }
string Modified { get; set; }
string Text { get; set; }
string When { get; set; }
}
}
【问题讨论】:
-
Am I using the right method to pull in the json?你试过了吗?statusCollection是什么,你在检查计数不是你,是什么?