【发布时间】:2017-03-06 16:48:13
【问题描述】:
我有这段 JSON:
{
"grid": 4,
"rows": [
{
"label": "Full Width",
"name": "FullWidth",
"areas": [
{
"grid": 16,
"hasConfig": false,
"controls": [
{
"value": "Test",
"editor": {
"name": "Headline",
"alias": "headline",
"view": "textstring",
"render": null,
"icon": "icon-coin",
"config": {
"style": "font-size: 36px; line-height: 45px; font-weight: bold",
"markup": "<h1>#value#</h1>"
}
},
"active": false
},
{
"value": "Test",
"editor": {
"name": "Headline",
"alias": "headline",
"view": "textstring",
"render": null,
"icon": "icon-coin",
"config": {
"style": "font-size: 36px; line-height: 45px; font-weight: bold",
"markup": "<h1>#value#</h1>"
}
},
"active": false
}
],
"active": false
}
],
"hasConfig": false,
"id": "e0f6ab79-f562-b86b-f32b-d5520173f0cb",
"active": false
}
]
}
我想知道是否有任何行(可能是多行)有任何控件(计数 > 0)。我不需要知道任何字段中包含什么,只要任何行的控制计数 > 0 - 所以只是对或错。我一直在尝试使用 LINQ 查询来实现这一点,但速度并不快!
这个 JSON 是动态的,所以我不能反序列化它。任何帮助将不胜感激! :)
【问题讨论】:
-
如果您的 JSON 数据没有具体类型,则只需将其反序列化为动态对象,然后按照 siddharthpandey.net/… 的说明检查该对象的控制计数,或者您也可以创建一个匿名只关心您需要的成员的类型,如此处所述siddharthpandey.net/…