我正在尝试使用 Linq.js 从数组中的 JSON 对象获取子集元素。
我有一组 JSON 对象,其中一个看起来像这样
{
"geometryType":2,
"id":461219,
"layer":"V_TRASA",
"attributes":
[
{
"type":"String","name":"DIMENZE","invariantStringValue":"80"
},
{
"type":"String","name":"DRUH","invariantStringValue":"nezadáno"
},
{
"type":"String","name":"ETAPA","invariantStringValue":"nezadáno"
},
{
"type":"Long","name":"ID","invariantStringValue":"461219"
},
{
"type":"String","name":"JMTLAK","invariantStringValue":"nezadáno"
},
{
"type":"String","name":"MATERIAL","invariantStringValue":"litina"
},
{
"type":"String","name":"RC","invariantStringValue":"Vodovodní řad, geod.zaměření"
},
{
"type":"String","name":"ULOZENI","invariantStringValue":"zem"
}
],
"mbr":
{
"xmin":-496466.545,
"ymin":-1155042.47,
"xmax":-496466.11,
"ymax":-1155042.145
},
"lineSymbology":
{
"IRgbColor":-16776961,
"lineWeight":2
},
"points":
[
{"x":-496466.545,"y":-1155042.145},
{"x":-496466.11,"y":-1155042.47}
]
}
每个对象都有数组属性。例如,当我需要layer = V_TRASA and ID >460000
将使用此查询的元素时,我可以根据其属性从数组中选择元素
var queryResult2 = Enumerable.From(myArray)
.Where("$.layer == 'V_TRASA' && $.id>460800" )
.Select("$")
.ToArray();
但是我需要对数组的 attributes 属性进行一些子查询,例如我需要查询何时$.layer == 'V_TRASA'
和元素包含 attribute name =='DIMENZE' and invariantStringValue == 80
。
我是 Linq 的新手,所以很难从我这里构建这个查询。
谢谢你的帮助