[英]How to loop through array JSONATA
Here is my array:这是我的数组:
{
"tocontrol": [{"name": "john"},{"name": "doe"}]
}
I'm expecting below output:我期待低于 output:
{
"method": "OR",
"match": [
{
"match": {
"name": "jhon"
}
},
{
"match": {
"name": "doe"
}
}
]
}
I've tried $join function but not getting the expected result.我试过 $join function 但没有得到预期的结果。
Can someone help me to get expected output?有人可以帮助我获得预期的 output 吗? Thanks!谢谢!
In order to achieve the desired result, you need to use a .
为了达到预期的结果,您需要使用.
(map) expression: https://docs.jsonata.org/path-operators#-map (地图)表达式: https://docs.jsonata.org/path-operators#-map
This is what the finished result looks like:这是最终结果的样子:
{
"method": "OR",
"match": tocontrol.{
"name": name
}
}
Link to JSONata exerciser: https://try.jsonata.org/NuR_JI3ua JSONata 练习器链接: https://try.jsonata.org/NuR_JI3ua
By the way, I've built this solution in 2 minutes by using the Mappings tool that my team is building at Stedi .顺便说一下,我使用我的团队在Stedi构建的映射工具在 2 分钟内构建了这个解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.