Changes

Jump to navigation Jump to search
85 bytes added ,  22:44, 14 August 2011
no edit 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 transformation is based on the following rules:
# The resulting document has a <code><json/></code> root node.
# JSON Names (keys ) of objects are represented as elements: ## Empty keys and values of arrays (which have no keys) names are represented by a single underscore (<code>&lt;_&gt;...&lt;/_&gt;</code>).## Underscores in the key Underscore characters are rewritten to two underscores (<code>__</code>).
## A character that cannot be represented as NCName character is rewritten to an underscore and its four-digit Unicode.
# As arrays have no names, {@code <value/>} is used as element name.
# JSON values are represented as text nodes.
# The types of values are represented in attributes:
## The value types ''number'', ''boolean'', ''null'', ''object'' and ''array'' are represented by a <code>type</code> attribute.
## The ''string'' type is omitted, as it is treated as default type.
## If a key name has the same type throughout the whole document, the <code>type </code> attribute will be omitted. Instead, the key name will be listed in additional, type-specific attributes in the root node. The attributes are named by their type in the plural (''numbernumbers'', ''booleanbooleans'', ''nullnulls'', ''objectobjects'' or and ''arrayarrays'') , and will contain the attribute value contains all relevant keys as valuenames with that type, separated by whitespaces.
|-
| valign='top' | '''Errors'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu