Thanks for the test case, Vincent,

Indeed it’s not RESTXQ, but the behavior of http:send-request that has
changed: Instead of passing a string representation of JSON to the
function, you can (well, need to) directly pass one of the BaseX JSON
representations, either as third function argument…

  let $body := { "items": [ ["item 1", "item 2", "item 3"] ] }
  let $request :=
    <http:request method="post" json="format=xquery,lax=true">
      <http:header name="Content-Type" value="application/json"/>
      <http:body media-type="application/json"/>
    </http:request>
  let $response := http:send-request($request, $url, $body)

…or within the http:body element in the XML notation:

  <http:body media-type="application/json">{
    json:parse($json-string)
  }</http:body>

As indicated in the first example, the 'map' keyword will become optional
with XQuery 4.0, so in many cases you can directly copy and paste JSON to
your query.

Hope this helps,
Christian

Reply via email to