Changes

Jump to navigation Jump to search
47 bytes added ,  14:18, 15 November 2017
no edit summary
This [[Module Library|XQuery Module]] contains functions to parse and serialize JSON documents. data [http://www.json.org/ JSON (JavaScript Object Notation)] is a popular data exchange format for applications written in JavaScript. As there are notable differences between JSON and XML, or XQuery data types, no mapping exists that guarantees a lossless, bidirectional conversion between JSON and XML. For this reason, we offer various mappings, all of which are suited to different use cases.
=Conventions=
===XQuery===
The {{Code|xquery}} format is lossless, too. It converts a JSON document data to an XQuery value (a map, array, string, number, boolean, or empty sequence) and vice versa. The conversion rules are the same as for [[XQuery 3.1#fn:parse-json|fn:parse-json]].
The resulting representation consumes less memory than XML-based formats, and values can be directly accessed without conversion. Thus, it is recommendable for very large inputs and for efficient ad-hoc processing.
| {{Code|merge}}
| This option is considered when {{Code|direct}} or {{Code|attributes}} conversion is used:<br/>
* If a name has the same type throughout the documentdata, the {{Code|type}} attribute will be omitted. Instead, the name will be listed in additional, type-specific attributes in the root node.
* The attributes are named by their type in plural (''numbers'', ''booleans'', ''nulls'', ''objects'' and ''arrays''), and the attribute value contains all names with that type, separated by whitespaces.
| {{Code|yes}}, {{Code|no}}
|-
| '''Summary'''
|Converts the JSON document data specified by {{Code|$input}} to an XML document or a mapXQuery value. If the input can be successfully parsed, it can be serialized back to the original JSON representation. The {{Code|$options}} argument can be used to control the way the input is converted.
|-
| '''Errors'''
|-
| '''Summary'''
|Serializes the node specified by {{Code|$input}} as JSON, and returns the result as {{Code|xs:string}} instance. The node input is expected to conform to the output results that are created by the [[#json:parse|json:parse()]] function. All other Non-conforming items will be serialized as specified for the [[XQuery 3.1#JSON Serialization|json output method]] of the official specification.<br />Items can also be serialized as JSON if the [[Serialization|Serialization Parameter]] {{Code|method}} is set to {{Code|json}}.<br/>The {{Code|$options}} argument can be used to control the way the input is serialized.
|-
| '''Errors'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu