【发布时间】:2020-12-08 21:48:32
【问题描述】:
我有一个不一致的 JArray 项,如下所示,有时它具有事件属性,但我需要根据事件值进行计数。
[
{
"id": 114792,
"attributes": {
"priority": 0
}
},
{
"id": 114792,
"attributes": {
"priority": 0,
"event": 10
}
},
{
"id": 114793,
"attributes": {
"priority": 0,
"event": 0
}
}
]
如何根据例如 event = 0 的条件进行计数? 我在下面尝试过:
_ja.Select(x => x.ToObject<JObject>()).Where(x => (int)x["attributes"]["event"] == 0).Count();
【问题讨论】: