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 m.lettere@gmail.com 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 ...:) };
- Replacing comment with the following code correctly returns an empty
object:
let $out := (<json type="object"></json>) return $out
- 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
- 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}
- 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.