0
我需要解析JSON文件的文件名看起來如下:如何獲得令牌
{"20120101":{"Jeff":{"Status":"Sleepy", "Weight":212}, "Cathy":{"Status":"Angry", "Weight":172}}
{"20120102":{"Jeff":{"Status":"Alert", "Weight":207}, "Cathy":{"Status":"Sick", "Weight":168}}
我不能想出一個辦法來提取日期(20120101和20120102)和名稱(傑夫和卡西)從我的JSON。我嘗試如下所示:
private void LoadFile(string fileName)
{
var json = File.ReadAllText(fileName);
JObject days = JObject.Parse(json);
foreach (var dayAsObject in days)
{
var day = (JToken) dayAsObject;
var a = day.Root.ToString();
var t = day.ToString();
var z = day.First;
Console.WriteLine(day+t+z+a);
}