Created
January 25, 2023 18:43
-
-
Save joewiz/4f06d44794a268d2b262034b31eac5c4 to your computer and use it in GitHub Desktop.
Sample code using eXist-db json-ignore-whitespace-text-nodes parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(: @see https://github.com/eXist-db/exist/commit/53bdb54c664a8063e43392e0b0fb9eac57baf67d#diff-fc5225a3545e6b6807e7810bc9e40219500842a68dbb49a7eb83670016b160ab :) | |
declare boundary-space preserve; | |
let $json-ignore-whitespace-text-nodes-param-xml := | |
<output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"> | |
<output:method value="json"/> | |
<exist:json-ignore-whitespace-text-nodes value="yes"/> | |
</output:serialization-parameters> | |
let $json-ignore-whitespace-text-nodes-param-map := | |
map { | |
"method": "json", | |
"exist:json-ignore-whitespace-text-nodes": true() | |
} | |
let $source := | |
<a z='99'> | |
<b x='1'/> | |
<b x='2'></b> | |
<b x='3'>stuff</b> | |
<b x='4'> </b> | |
</a> | |
return | |
( | |
fn:serialize($source, $json-ignore-whitespace-text-nodes-param-xml), | |
fn:serialize($source, $json-ignore-whitespace-text-nodes-param-map) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"z":"99","b":[{"x":"1"},{"x":"2"},{"x":"3","#text":"stuff"},{"x":"4"}]} | |
{"z":"99","b":[{"x":"1"},{"x":"2"},{"x":"3","#text":"stuff"},{"x":"4"}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment