Upgrading to the Zorba2 and Zorba3 libraries will provide developers an easier set of APIs to interact with JSON data. The Zorba2 and Zorba3 libraries are already included in the Strategy installation and only require a flag to be enabled on the XQuery database instance. The Zorba3 option is included in version 2021 Update 10. Compared with Zorba2, Zorba3 performance improved in the Strategy.





Refer to the code sample below for an example that leverages Zorba2 and Zorba3 libraries.
NOTE: Zorba 2/3 libraries will not work in the XEG tool.
import module namespace jn = "http://jsoniq.org/functions";
declare copy-namespaces no-preserve, no-inherit;
declare namespace mstr-rest = 'http://www.Strategy.com/xquery/rest-functions';
declare function mstr-rest:post($uri,$payload,$header) external;
let $header := ('')
let $uri := ('https://jsonplaceholder.typicode.com/posts')
let $payload := ( )
let $jsonresult := mstr-rest:post($uri,$payload,$header)
let $result := jn:parse-json($jsonresult)
let $resultarr := jn:members($result)
return
<Table><ColumnHeaders>
<ColumnHeader name='userId' type='xs:number' />
<ColumnHeader name='id' type='xs:number' />
<ColumnHeader name='title' type='xs:string' />
<ColumnHeader name='body' type='xs:string' />
</ColumnHeaders>
<Data>
{for $entry in $resultarr
let $userId := $entry("userId")
let $id := $entry("id")
let $title :=$entry("title")
let $body := $entry("body")
order by $id
return
<Row>
<userId>{fn:data($userId)}</userId>
<id>{fn:data($id)}</id>
<title>{fn:data($title)}</title>
<body>{fn:data($body)}</body>
</Row>
}
</Data>
</Table>

The resulting report will look like the below screenshot:

For Zorba3, you can refer to http://www.zorba.io/documentation/latest/modules/jsoniq/core to create SQL and refer to http://www.zorba.io/documentation/latest/zorba/xml_json/ for support with the new JSONiq language.