Package org.basex.io.parse.json
Class JsonDirectConverter
- java.lang.Object
-
- org.basex.io.parse.json.JsonConverter
-
- org.basex.io.parse.json.JsonDirectConverter
-
public final class JsonDirectConverter extends JsonConverter
This class converts a JSON document to XML. 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 specified JSON input is first transformed into a tree representation and then converted to an XML document, according to the following rules:
- The resulting document has a
<json/>
root node. - Names (keys) of objects are represented as elements:
- Empty names are represented by a single underscore
(
<_>...</_>
). - Underscore characters are rewritten to two underscores (
__
). - A character that cannot be represented as NCName character is rewritten to an underscore and its four-digit Unicode.
- Empty names are represented by a single underscore
(
- As arrays have no names,
<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
type
attribute. - The string type is omitted, as it is treated as default type.
- If a name has the same type throughout the document, the
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 the plural (numbers, booleans, nulls, objects and arrays), and the attribute value contains all names with that type, separated by whitespace.
- The value types number, boolean, null,
object and array are represented by a
- Author:
- BaseX Team 2005-24, BSD License, Christian Gruen, Leo Woerteler
- The resulting document has a
-
-
Field Summary
-
Fields inherited from class org.basex.io.parse.json.JsonConverter
fallback, jopts, nullValue, numberParser, shared
-
-