XML Methodology
This page describes how the different POJO datatypes are represented in XML. The representations mirror how the same data structures are represented in JSON:
- Simple values (strings, numbers, booleans, nulls) render as elements named after their datatype (
<string>,<number>,<boolean>,<null/>) when loose (not a direct bean property value). Mapsand beans render inside<object>elements.Collectionsand arrays render inside<array>elements.
The examples below show one representative case per category.
For the complete set of data-type representations (all Map, array, Collection, and bean shapes), see the reference tables on the XML Serializers page.
Simple types
The representation of loose (not a direct bean property value) simple types are shown below:
| Data type | JSON example | XML |
|---|---|---|
| string | | |
| boolean | | |
| integer | | |
| float | | |
| null | | |
Objects
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).
The following representative example shows a bean containing simple values, a value whose type must be tagged, a nested bean, and array properties:
| Data type | JSON example | XML |
|---|---|---|
| | |
Arrays and collections
Loose collections and arrays use the element <array> for encapsulation.
Collections (e.g. List, Set) serialize identically to their array equivalents.
The following representative example shows a mixed-type Object[]:
| Data type | JSON example | XML |
|---|---|---|
| Object[] | | |