Changes

Jump to navigation Jump to search
1,068 bytes added ,  18:46, 24 September 2013
no edit summary
|-
| '''Summary'''
|Converts the JSON document specified by {{Code|$input}} to XML, and returns the result as {{Code|element(json)}} instance. The converted XML document is both well readable and lossless, i.e., the converted document can be serialized back to the original JSON representation.<br/>The {{Code|$options}} argument can be used to control the way the input is converted. The following options are available (they bear resemblance to the one ones specified in [http://www.w3.org/TR/xslt-30/#json XSLT 3.0]):
* {{Code|spec}} determines the used JSON specification. Allowed values are {{Code|RFC4627}}, {{Code|ECMA-262}}, and {{Code|liberal}}; the default is ({{Code|RFC4627}}).
* {{Code|unescape}} determines whether escape sequences (marked by a backslash) in the input are expanded. The default is {{Code|true}}.
* {{Code|format}} determines the conversion format. Allowed values are {{Code|json}}, {{Code|jsonml}}, and {{Code|map}}; the default is {{Code|truejson}}.
Options can either be specified<br />
* as children of an {{Code|<json:options/>}} element; e.g.:
<pre class="brush:xml">
<json:options>
<json:spec format value='liberaljsonml'/>
...
</json:options>
* or as map, which contains all key/value pairs:
<pre class="brush:xquery">
{ 'specformat' : 'liberaljsonml', ... }
</pre>
|-
|-
| width='120' | '''Signatures'''
|{{Func|json:serialize|$input as node()|xs:string}}<br/>{{Func|json:serialize|$input as node(), $options as item()|xs:string}}
|-
| '''Summary'''
|Serializes the node specified by {{Code|$input}} as JSON, and returns the result as {{Code|xs:string}} instance. The serialized node must conform to the syntax specified by the [[#json:parse|json:parse()]] function.<br />XML documents can also be serialized as JSON if the [[Serialization|Serialization Option]] {{Code|"method"}} is set to {{Code|"json"}}.<br/>The {{Code|$options}} argument can be used to control the way the input is serialized. The following options are available (they bear resemblance to the ones specified in [http://www.w3.org/TR/xslt-30/#json XSLT 3.0]):* {{Code|spec}} determines the used JSON specification. Allowed values are {{Code|RFC4627}}, {{Code|ECMA-262}}, and {{Code|liberal}}; the default is ({{Code|RFC4627}}).* {{Code|unescape}} determines whether escape sequences (marked by a backslash) in the input are expanded. The default is {{Code|true}}.* {{Code|format}} determines the conversion format. Allowed values are {{Code|json}}, {{Code|jsonml}}, and {{Code|map}}; the default is {{Code|json}}.Options can either be specified<br />* as children of an {{Code|<json:options/>}} element; e.g.:<pre class="brush:xml"><json:options> <json:format value='jsonml'/> ...</json:options></pre>* or as map, which contains all key/value pairs:<pre class="brush:xquery">{ 'format' : 'jsonml', ... }</pre>
|-
| '''Errors'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu