Changes

Jump to navigation Jump to search
142 bytes removed ,  15:39, 14 August 2011
no edit summary
[http://www.json.org/ JSON] (JavaScript Object Notation) is a popular data exchange format for applications written in JavaScript. This module contains [[Querying#Functions|XQuery functions]] to parse and serialize JSON documents. All functions are preceded by the <code>json:</code> prefix, which is linked to the <code><nowiki>http://www.basex.org/json</nowiki></code> namespace.
The [[proposed JSON Functions#json:parse|json:parse()]] function converts a JSON document to XML. The converted XML document is both well readable and lossless, i.efunctions will be available with <font color="red">Version 6., the converted document can be serialized back to the original JSON representation8</font> of BaseX. The transformatio is based on the following rules:
==json:parse==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>json:parse</b>($input as xs:string()) as element(json)</code>
|-
| valign='top' | '''Summary'''
|Converts the JSON document specified by <code>$input</code> to XML, and returns the result as <code>element(json)</code> 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. The transformatio is based on the following rules:
# The resulting document has a <code><json/></code> root node.
# JSON keys are represented as elements:
## String and object types are omitted as they are treated as default types for flat elements and and nested elements with/without names.
## If a key has the same type throughout the whole document, the type attribute will be omitted. Instead, the key will be listed in additional, type-specific attributes in the root node. The attributes are named by their type (number, boolean, null or array) and will contain all relevant keys as value, separated by whitespaces.
 
The proposed JSON functions will be available with <font color="red">Version 6.8</font> of BaseX.
 
==json:parse==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>json:parse</b>($input as xs:string()) as element(json)</code>
|-
| valign='top' | '''Summary'''
|Converts the JSON document specified by <code>$input</code> to XML, following the rules described in the introduction, and returns the result as <code>element(json)</code> instance.
|}
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu