I am looking to convert xquery to 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)
Any kind of assistance and help is much appreciated.
Thanks in advance.
Your XQuery is a
for
expression that can be easily rewritten as a simple XPath path expression/bookstore/book[price > 30]/title
which would translate to a JSONata pathbookstore.book[price > 30].title
. On the other hand it is unlikely that the JSON data has such a structure withbookstore
andbook
, I guess an object with an array property likewhich leads to
bookstore[price > 30].title
(https://try.jsonata.org/0vfDXqv4m) or a simple array with the book objectswhich leads to
$[price > 30].title
(https://try.jsonata.org/fryxG-QLj) is more likely.