Hi Vincent,

Could you give us additional information on how you dispatch your HTTP
request? With the following request, everything seems to work fine:

input.json:
  { "items": [ ["item 1", "item 2", "item 3"] ] }
command:
  curl -H"Content-Type:application/json" -XPOST -Tinput.json "
http://localhost/my/function";

In addition, feel free to run your query with the latest snapshot [1],
which includes fixes for the processing of data that is incoming through
RESTXQ endpoints.

Best,
Christian

[1] https://files.basex.org/releases/latest/


On Thu, Jan 30, 2025 at 8:17 PM Lizzi, Vincent <
[email protected]> wrote:

> Hi BaseX folks,
>
>
>
> I’m encountering a problem in updating to BaseX 11.6 from 11.3
>
>
>
> I have a RESTXQ function defined like this:
>
>
>
> declare
>
>   %rest:POST("{$body}")
>
>   %rest:path("/my/function")
>
>   %rest:consumes('application/json')
>
>   %input:json('format=xquery')
>
> function my:function (
>
>   $body
>
> ) as element(rest:forward) {
>
>   let $items as xs:string* := array:flatten($body?items)
>
>   (: omitted logic :)
>
>   return web:forward()
>
> }
>
>
>
> Everything works as expected using BaseX versions 11.3 up to 11.5, but
> with 11.6 an error occurs with the lookup operator and produces this error
> message:
>
>
>
> err:XPTY0004 Input of lookup must be map or array
>
>
>
> I did an experiment to try isolating the problem:
>
>
>
> let $json := '{ "items": [ ["item 1", "item 2", "item 3"] ] }'
>
> return array:flatten(json:parse($json, map{'format': 'xquery'})?items)
>
>
>
> but this produced the expected list of items without error.
>
>
>
> Has something changed in BaseX version 11.6 specifically in JSON parsing
> in RESTXQ?
>
>
>
> Thanks,
>
> Vincent
>
>
>
>
>
> ______________________________________________
>
> *Vincent M. Lizzi*
>
> Head of Information Standards | Taylor & Francis Group
>
> 530 Walnut St., Suite 850, Philadelphia, PA 19106
>
> E-Mail: [email protected]
>
> Web: www.tandfonline.com
>
>
>
> Taylor & Francis is a trading name of Informa UK Limited,
>
> registered in England under no. 1072954
>
>
>
> "Everything should be made as simple as possible, but not simpler."
>
>
>
> Information Classification: General
>

Reply via email to