Thank you very much, Gerrit, interesting! But I am unwilling to get tangled up (in blue, like Bob Dylan, or not), I want clarity. It could not be simpler: I want to preserve information content, character for character: (a) when parsing JSON syntax into an XML node tree, (b) when serializing an XML node tree representation of JSON into JSON syntax.  At least I want clean roundtripping, where output information is equal to input information. (Which is a lesser requirement than a+b.).

Currently, it is not clear to me how to do it, and I want to learn. Besides, I think it is a bug if roundtripping involves a change of information.

If I oversimplify things, I would like to learn why.

Have a cozy Sunday -
Hans

PS: To demonstrate the issue:

let $j1 := '{"key":"a/b"}'
let $x := json:parse($j1)
let $j2 := json:serialize($x)
return ($j1, $x, $j2)

yields:

{"key":"a/b"}
<json type="object">
  <key>a/b</key>
</json>
{
  "key":"a\/b"
}

PPS: Please do not even dream of thinking about considering or not excluding to change the parsers behaviour which leaves the slash as it is - otherwise you cannot use JSON information in XML representation without wiggling around - e.g. follow links, imagine. It's the serializer who gets it wrong.

Am Samstag, 20. März 2021, 23:52:06 MEZ hat Imsieke, Gerrit, le-tex <gerrit.imsieke@le-tex.de> Folgendes geschrieben:


Hi Hans-Jürgen,

Maybe this thread and the linked sources can shed some light on the
annoying slash escaping:

https://www.mhonarc.org/archive/html/xsl-list/2019-10/msg00078.html

Gerrit

On 20.03.2021 11:11, Hans-Juergen Rennau wrote:
> Dear BaseX team,
>
> there is something I don't understand about the parsing/serializing of JSON.
>
> When I serialize a document without options, backslashes are escaped. So
> for example ...
>
> <url>https://help.openconnectors.ext.hana.ondemand.com/home/google-analytics</url>
>    becomes
> "url":"https:\/\/help.openconnectors.ext.hana.ondemand.com\/home\/google-analytics"
>
> Only using serialization options - map{"escape": "no"} - do I get the
> output as expected, corresponding to the input.
>
> Why are slashes by default escaped when serializing JSON?
>
> Kind regards,
> Hans-Jürgen
>
> PS: When parsing, the slashes are not escaped, so it is "asymmetrical" -
> I need to parse without options, yet to serialize with options.