From: Nick S. <nsi...@nu...> - 2020-12-21 07:20:52
|
I have a script where I am trying to convert XML to JSON. It looks like this: xquery version "3.1"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare namespace json="http://www.json.org"; (: Switch to JSON serialization :) declare option output:method "json"; declare option output:media-type "text/javascript"; let $servers-list := collection('/db/apps/partners-packages/control-center/data')//server return <servers>{$servers-list}</servers> The output looks like this: { "server" : [{ "#text" : ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n " ], "id" : "1", "name" : "Indian Server", "status" : "active", "ip-address" : "XXX.XXX.XXX.XXX", "port" : "8080", "type" : "single-delivery-system", "description" : "Server which supports many clients in India" }, { "#text" : ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n " ], "id" : "2", "name" : "N.Va.A HUB", "status" : "active", "ip-address" : "XXX.XXX.XXX.XXX", "port" : "8080", "type" : "auto-scaling-hub", "description" : "Auto scaling hub in N.Va Region" }, { "#text" : ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n " ], "id" : "3", "name" : "N.Va.B HUB", "status" : "active", "ip-address" : "XXX.XXX.XXX.XXX", "port" : "8080", "type" : "auto-scaling-hub", "description" : "Auto scaling hub in N.Va Region" }, { "#text" : ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n " ], "id" : "4", "name" : "Video", "status" : "active", "ip-address" : "XXX.XXX.XXX.XXX", "port" : "8080", "type" : "single-delivery-system" }] } I was wondering if there was a way to get rid of all of these #text arrays that get generated: "#text" : ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n " ] This array of newline characters goes away if my XML is not formatted in a easy-to-read format. Is there a serialization setting that I can set that will make these go away? Nick -- Nick Sincaglia President/Founder NueMeta, LLC Digital Media & Technology Phone: +1-630-303-7035 nsi...@nu... http://www.nuemeta.com Skype: nsincaglia |