JSONAta 获取包含值的键的名称
我正在使用jsonata库通过一个复杂的对象。如果键匹配特定条件,我需要获取钥匙的名称。
{
"properties": {
"WTID": {
"pattern": "reference-data",
"type": "string"
},
"VCRSID": {
"pattern": "reference-data",
"type": "string"
},
"VMSID": {
"pattern": "reference-data",
"type": "string"
},
"DroneID": {
"pattern": "unique-data",
"type": "string"
}
}
}
我想要的所有名称的键都等于参考数据,即wtid,vcrsid,vmsid。如何使用JSONATA查询如何进行操作。
到目前为止,我已经尝试使用以下查询:
**[$contains(pattern, 'reference-data')]
但这仅返回值,我无法参考任何键。
I am using JSONAta library to pass through a complex object. I need to get the name of the keys if it matches a certain condition.
{
"properties": {
"WTID": {
"pattern": "reference-data",
"type": "string"
},
"VCRSID": {
"pattern": "reference-data",
"type": "string"
},
"VMSID": {
"pattern": "reference-data",
"type": "string"
},
"DroneID": {
"pattern": "unique-data",
"type": "string"
}
}
}
I want all the name of the keys whose pattern is equal to reference-data i.e. WTID, VCRSID, VMSID. How is it possible to do using JSONAta Query.
So far I have tried using below query:
**[$contains(pattern, 'reference-data')]
but this returns only the values and I am unable to refer to any of the keys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您期望
[“ wtid”,“ vcrsid”,“ vmsid”]
因此,这就是解决方案:properties
object的所有键作为数组。$键
in属性
对象的值。模式
从对象从上一步等于“ Reference-data”
您还可以使用interactive version of this solution here.
If you're expecting
["WTID", "VCRSID","VMSID"]
as a result, then this is the solution:properties
object as an array.$key
insideproperties
object.pattern
property from the object from the previous step equals to"reference-data"
You can also play with the interactive version of this solution here.