This library provides XML related JSON handlers for other JSON processing libraries.
Consult the documentation and the usage description for further information:
This library is hosted in the Maven Central Repository. You can use it with the following coordinates:
<dependency>
<groupId>net.markenwerk</groupId>
<artifactId>utils-json-handler-xml</artifactId>
<version>2.0.1</version>
</dependency>
A XmlDocumentJsonHandler
is a JsonHandler
that creates a XML Document
, that represents the described JSON document, using the following rules:
- A JSON array is represented as a tag with name
array
. - A JSON object is represented as a tag with name
object
. - A JSON object entry is represented as a tag with name
entry
. - The name of a JSON object entry is represented as an attribute of the
entry
tag with namename
. - A JSON null is represented as a tag with name
null
. - A JSON boolean is represented as a tag with name
boolean
. - The value of the JSON boolean represented as an attribute of the
boolean
tag with namevalue
. - A JSON number is represented as a tag with name
number
. - The value of the JSON boolean represented as an attribute of the
number
tag with namevalue
. - A JSON string is represented as a tag with name
string
. - The value of the JSON boolean represented as an attribute of the
string
tag with namevalue
.
// a JsonDocument
JsonDocument document = ...
// returns a xml document
Document xmlDocument = document.handle(new XmlDocumentJsonHandler());
The returned XML Document
for the example.json
has the following content:
<?xml version="1.0" encoding="UTF-8"?>
<object>
<entry name="null">
<null />
</entry>
<entry name="boolean">
<boolean value="true" />
</entry>
<entry name="longValue">
<number value="-42" />
</entry>
<entry name="double">
<number value="-23.42" />
</entry>
<entry name="array">
<array>
<string value="foo" />
<string value="bar" />
</array>
</entry>
</object>