Am 27.02.2020 um 08:29 schrieb Johannes Bauer:
Am 27.02.2020 um 08:25 schrieb Johannes Bauer:
Am 27.02.2020 um 08:15 schrieb Martin Honnen:
Am 27.02.2020 um 07:49 schrieb Johannes Bauer:
I'm trying to deactivate the escaping of characters for JSON serialization.
It does not work with this:
let $json := <map xmlns="http://www.w3.org/2005/xpath-functions"> <string key="url">http://some.url/path/to/somewhere</string></map> return json:serialize($json, map {'format' : 'basic', 'escape': 'no'})
Output: { "url":"http://some.url/path/to/somewhere" }
Does
serialize(<map xmlns="http://www.w3.org/2005/xpath-functions"> <string key="url">http://some.url/path/to/somewhere</string></map>, map { 'method' : 'json', 'use-character-maps' : map { '/' : '/'}})
do what you want?
unfortunately no, I still get the "/" in the output with:
serialize( <map xmlns="http://www.w3.org/2005/xpath-functions"> <string key="url">http://some.url/path/to/somewhere</string> </map>, map {'method': 'json', 'use-character-maps': map { '/' : '/'}, 'json': map {'format' : 'basic'}} )
<map xmlns="http://www.w3.org/2005/xpath-functions"> <string key="url">http://some.url/path/to/somewhere</string></map> => xml-to-json() => parse-json() => serialize(map { 'method': 'json', 'use-character-maps' : map { '/' : '/' }})
gives the JSON with unescaped slashes for me in BaseX and Saxon. Not sure there is a more compact way, either BaseX specific or for XQuery in general, to achieve this. I am sure Christian can tell you.