XML Serializers
The XmlSerializer class is used to serialize POJOs into XML.
The XmlDocSerializer class is the same but serializes a
<?xml?> header at the top of the file.
The class hierarchy for the builder of this serializer is:
Refer to the builder javadocs for configurable settings.
The following pre-configured serializers are provided for convenience:
Data type representations
The following tables are the complete reference for how each POJO datatype is rendered by XmlSerializer.
They mirror how the same data structures are represented in JSON.
See XML Methodology for a conceptual overview of the mapping rules.
Maps
Loose maps and beans use the element <object> for encapsulation.
_type attributes are added to bean properties or map entries if the type cannot be inferred through reflection (e.g.
an Object or superclass/interface value type).
| Data type | JSON example | XML |
|---|---|---|
| Map | | |
| Map | | |
| Map | | |
Arrays and collections
Loose collections and arrays use the element <array> for encapsulation.
Collections (e.g. List, Set) serialize identically to their array equivalents.
| Data type | JSON example | XML |
|---|---|---|
| String[] | | |
| Number[] | | |
| Object[] | | |
| String[][] | | |
| int[] | | |
| boolean[] | | |
| List<String> | | |
| List<Number> | | |
| List<Object> | | |
Beans
| Data type | JSON example | XML |
|---|---|---|
| | |
Beans with Map properties
| Data type | JSON example | XML |
|---|---|---|
| | |