我希望将xquery转换为jsonata,
let $h := $at//datahistory
for $x in 0 to (count($h))
let p:= (if (not($h[$x]/daytoday =(‘one’, ‘two’) )) then ‘ZERO’ else $h[$x+1]/Status
return if(index-of($p) > 0 then 0 else 1)任何形式的帮助和帮助都是非常感谢的。
提前谢谢。
发布于 2020-09-27 05:41:03
您的XQuery是一个for表达式,可以很容易地重写为一个简单的XPath路径表达式/bookstore/book[price > 30]/title,它将转换为一个JSONata路径bookstore.book[price > 30].title。另一方面,JSON数据不太可能具有这样的具有bookstore和book的结构,我猜是具有如下数组属性的对象
{
"bookstore" : [
{
"title" : "title 1",
"price" : 20
},
{
"title" : "title 2",
"price" : 35
},
{
"title" : "title 3",
"price" : 99
}
]
}这将导致bookstore[price > 30].title (https://try.jsonata.org/0vfDXqv4m)或一个包含图书对象的简单数组
[
{
"price": 20,
"title": "title 1"
},
{
"price": 35,
"title": "title 2"
},
{
"price": 99,
"title": "title 3"
}
]这导致了$[price > 30].title (https://try.jsonata.org/fryxG-QLj)的可能性更大。
https://stackoverflow.com/questions/64076818
复制相似问题