我有以下代码:
JToken hours = jToken["hours"];
它返回以下 JSON:
{
"monday": [
["11:00", "21:30"]
],
"tuesday": [
["11:00", "21:30"]
],
"wednesday": [
["11:00", "21:30"]
],
"thursday": [
["11:00", "21:30"]
],
"friday": [
["11:00", "2:00"]
],
"saturday": [
["11:00", "2:00"]
],
"sunday": [
["11:00", "21:30"]
]
}
我需要将其解析为类型化的集合,例如
<string, string>
或为任何一天选择一个值,例如
hours.Where(p=>p["monday"].Value<string>())
我试过:
IList<JToken> a = hours.Children().ToList();
var a = JsonConvert.DeserializeObject<Pair<string, string>>(hours.Value<string>());
var a = hours["monday"];
hours.Where(p=>p["monday"].Value<string>())
没有工作。