Hi Rob
the behavior is correct:
declare option output:method 'json'; serialize( <a>test</a> )
The result is:
"<a>test</a>"
…as specified in [1].
serialize( <a>test</a> , map{ 'method' : 'json'} )
The result is:
"<a>test</a>"
The node will first be serialized to a string, and the query result (i.e., this string) will be serialized according to the XML serialization rules. You can switch to plain text serialization as follows:
declare option output:method 'text'; serialize( <a>test</a>, map{ 'method' : 'json'} )
declare option output:method 'json'; serialize( <a>test</a> , map{ 'method' : 'json'} )
The result is:
""<a>test</a>""
The node will first be serialized to a string, and the query result (i.e., this string) will be serialized according to the JSON serialization rules. In a JSON string, quotes will be backslashed.
Cheers, Christian
[1] http://www.w3.org/TR/xslt-xquery-serialization-31/#JSON_JSON-NODE-OUTPUT-MET...