Package net.sf.practicalxml.converter.json

This package contains classes to convert JSON (JavaScript Object Notation) strings (as defined json.org ) to and from an XML DOM.

See: Description

Package net.sf.practicalxml.converter.json Description

This package contains classes to convert JSON (JavaScript Object Notation) strings (as defined json.org ) to and from an XML DOM. Although both XML and JSON are textual representations of hierarchical data, there are some peculiarities in the conversion:
Container Element
Although elements within a JSON object are named, the object itself is not. XML requires a named root element, so the JSON to XML conversion creates a root element named "data", and the XML to JSON conversion ignores the passed root element.
Document Order
In XML, document order is important and may be validated; in JSON, the order of elements within an object is not important. To support arrays the XML to JSON conversion intentionally breaks document order (qv). And as JSON has no intrinsic order, you'll need to explicitly re-arrange the result of a JSON to XML conversion prior to any validation.
Non-String Data
JSON supports numbers and boolean literals in addition to quote-delimited strings. The JSON to XML conversion will handle these values transparently. The default XML to JSON conversion writes all content as quote-delimited strings, will optionally look for a type attribute and use it to generate unquoted values.
Arrays, XML to JSON
XML does not have a defined array construct, but may repeat elements; JSON has a defined array construct, and repeated elements will overwrite the former definition. To avoid this problem, the XML to JSON converter will create a JSON array construct from all siblings with the same localname.
Arrays, JSON to XML
By default, arrays are converted into a single parent element, with one child named "data" for each element of the array; this is similar to the Java to XML conversion. Optionally, you may convert an array into a series of repeated elements (siblings), all with the same name. When using this option, conversion will fail if presented with a top-level JSON array.