Skip to content
Engin1980 edited this page Jan 29, 2018 · 3 revisions

This page describes how null value is processed during serialization and deserialization.

Why

The fields declared in the class ale always mandatory in the XML file, except when marked with @XmlOptional, @XmlIgnored attributes, or when skipped due to settings exclude regex definitions. When you need to represent that the field has null value, it still must be present in the XML file.

How

To define that specific field has null value, it must contain a string defined in settings as null string. The default value is (null). This string must be as a value of attribute, like

<person name="John" surname="Doe" emptyAttribute="(null)" />

or as a text of xml-element, like

<person name="John" surname="Doe">
  <emptyElement>
    (null)
  </emptyElement>
</person>

To use different null string adjust the string in the serializer settings using the property nullString, like

Settings settings = new Settings();
settings.setNullString("--null--");

Project

Simple introduction

Common concepts

Clone this wiki locally