的定义,我有以下JSON:'Newtonsoft.Json.Linq.JArray' 不包含
{
"ok": true,
"resp": [
{
"aaa": 111,
"bbb": "xyz",
"ccc": [
{...},
{
"ddd": "hello",
"eee": 666,
},
{...}
],
"read": false
},
{...},
{...}
]
}
与此C#代码:
dynamic my_obj = JsonConvert.DeserializeObject(JSON);
var resps = my_obj.resp;
var x = ((IEnumerable<dynamic>)resps).Cast<dynamic>()
.Where(p => p.ccc.eee == 666).Count();
及以下错误:
'Newtonsoft.Json.Linq.JArray' does not contain a definition for 'eee'.
我知道,我可以通过所有元素“resps”迭代和计数元素,其中元素“ccc.eee”等于666,但有可能做到这一点在一条线的Wi th linq?
不是应该'CCC [1] .eee EEE = 666的
计数数'? –
如果你想使一个@UlugbekUmirov – Jonesopolis
这就是答案,认为OP具有与MongoDB的 – Rahul