我需要使用Newtonsoft.json反序列化此JSON:
{
"Monday": [
{
"begin": "08:00:00",
"end": "17:00:00",
"duration": "09:00:00"
}
],
"Tuesday": [
{
"begin": "08:00:00",
"end": "17:00:00",
"duration": "09:00:00"
}
]
}
答案 0 :(得分:0)
定义一个类Times
public class Times
{
public string Begin { get; set; }
public string End { get; set; }
public string Duration { get; set; }
}
将JSON反序列化为Dictionary<string, List<Times>>
。字典的键将是日期名称,例如Monday
,Tuesday
等
var dict = JsonConvert.DeserializeObject<Dictionary<string, List<Times>>>(jsonString);