[Simple-support] Serialization of nested lists, arrays
Brought to you by:
niallg
|
From: Bernhard G. <ber...@tu...> - 2012-04-26 16:00:13
|
Hello everybody,
I have a problem with serializing lists containing arrays, and I hope
that one of you can help me.
I have the following code:
@ElementList(entry="reading")
private List<BigDecimal[]> readings;
This is serialized as
<readings>
<reading length="2">42.5, 23.9</reading>
<reading length="2">5.7, 8.3</reading>
</readings>
But what I want is something like this (I don’t actually need the
length attribute):
<readings>
<reading length="2">
<value>42.5</value>
<value>23.9</value>
</reading>
<reading length="2">
<value>5.7</value>
<value>8.3</value>
</reading>
</readings>
I know that I can annotate a single array to get the inner
representation I want.
@ElementArray(entry = "value")
private BigDecimal[] reading;
<reading length="2">
<value>42.5</value>
<value>23.9</value>
</reading>
What I can’t figure out is how to combine these list and array
annotations or otherwise get the desired result.
I’d appreciate any advice.
Best regards,
Bernhard
|