我具有以下JSON结构,并且试图在“ prototypequery”下获取所有“属性”值。在此示例中,我要获取“名称”,“领导”,“联系人”,“年份”。
我尝试通过使用jsonobject.SelectTokens(“ prototypeQuery.Select..Property”,false)来获取此信息,但查询未返回任何Jtoken。我在foreach循环中使用了它,但它从未进入循环。
foreach (var item in jsonobject.SelectTokens("prototypeQuery.Select..Property", false))
还有其他方法可以获取所有“属性”值列表吗?
"prototypeQuery":{
"Version":2,
"From":[
{
"Name":"i",
"Entity":"IPS"
}
],
"Select":[
{
"Column":{
"Expression":{
"SourceRef":{
"Source":"i"
}
},
"Property":"Name"
},
"Name":"IPS.Name"
},
{
"Column":{
"Expression":{
"SourceRef":{
"Source":"i"
}
},
"Property":"Lead"
},
"Name":"IPS.Lead"
},
{
"Column":{
"Expression":{
"SourceRef":{
"Source":"i"
}
},
"Property":"Contact"
},
"Name":"IPS.Contact"
},
{
"Column":{
"Expression":{
"SourceRef":{
"Source":"i"
}
},
"Property":"Year"
},
"Name":"IPS.Year"
}
]
}
答案 0 :(得分:0)
在Select为数组且Property为Column字段的情况下,您可能想摆脱使用递归下降运算符,而将其专门用于数组。
$。prototypeQuery.Select [*]。Column.Property
给我正确的值。
答案 1 :(得分:0)
将其转换为Jtoken列表对我有用
IList<JToken> items = json.SelectTokens("prototypeQuery.Select..Property", false).ToList();