Hi Christian and Fabrice,
thanks for your suggestion which indeed makes sense! :D
Happy that at least my message has been useful for something else.
Regards,
Marco.

On 23/01/2017 17:24, Christian Grün wrote:
Hi Marco,

Fabrice has already given you the correct hint: Wrapping your json
elements with <json <json type='array'> should do the trick.

Anyway, thanks for the hint to the NullPointerException, this issue
has been fixed.

Cheers,
Christian




On Mon, Jan 23, 2017 at 9:31 AM, Marco Lettere <[email protected]> wrote:
Hello all,

this morning just stumbled into this issue and I'm wondering whether it
could be somehow smoothed up ...

I have the following RestXQ function:

declare
   %rest:path("/f")
   %rest:GET
   %output:method("json")
function a:f() {
   (:code ...:)
};

1) Replacing comment with the following code correctly returns an empty
object:

   let $out := (<json type="object"></json>)
   return $out

2) Replacing comment with the following code correctly returns an expected
exception (" [SERE0023] Only one item can be serialized with JSON." :

let $out := (<json type="object"></json>, <json type="object"></json>)
   return $out

3) Replacing comment with the following code returns a somewhat less
expected Null-pointer exception :

let $out := (<json type="object"></json>, <json type="object"></json>)
return array{$out}

4) In order to get the expected Json array I need to write the code like the
following:

  let $out := (<json type="object"></json>, <json type="object"></json>)
  return array{ $out ! json:parse(json:serialize(.), map{ "format" : "map"})
}

I'm not sure whether the array could be inferred from the sequence directly
in a pattern like 2. But I would expect that 3) should work. Isn't it?

Thanks for any explanation.

Regards,

Marco.


Reply via email to