Spin Plugin XML Serialization

Hi all,

We try to serialize a java.util.List of type String to XML using the spin plugin in version 1.2.1

	List<String> list = new ArrayList<>();
	
	list.add("TestValue1");
	list.add("TestValue2");
	
	System.out.println(XML(list).toString());

Unfortunately the result of serialization is an empty list so the content ( The two entries of type String) are missing.

<?xml version="1.0" encoding="UTF-8"?> <?/arrayList>

When saving it as process variable of course we have the same problem.
When using JSON or JAVA serialization format everything works fine but because of some reasons we prefer XML.

Does anyone have an idea why a serialization of a list to XML does not work as expected?

We are using camunda 7.4.0.

Best regards,

Markus

1 Like

Hi Markus,

Spin’s XML data format is based on JAXB and therefore limited to the features and restrictions JAXB has.

As far as I know, JAXB requires the object to be marshalled to be a domain object, i.e. a custom defined class. Therefore it is not possible to avoid a wrapper class. The solution that comes closest to what you want would be implementing the List interface and delegating all methods to an inner list instance. Of course that will require you to work with the custom List implementation everywhere where you work with ArrayList at the moment (see this stackoverflow answer).

Cheers,
Thorben

1 Like