Open yogurtearl opened 9 years ago
Is there any solution to this?
If not, what is the default serialization criteria?
@Order annotation
From: João Amaro <notifications@github.com>
To: ngallagher/simplexml simplexml@noreply.github.com Sent: Thursday, 11 February 2016, 18:26 Subject: Re: [simplexml] Fields are not serialized in declaration order on Android (#1)
Is there any solution to this?— Reply to this email directly or view it on GitHub.
That means that, in order to force a sequence in the serialization, we have to use that annotation. By other words, when not using this @Order annotation, the serialization order is impredictable, is that it? Because changing the field declaration order won't have any effect on the serialization, as it was expected to be.
Java in general offers no way to determine declaration order, if you can think of a way to do it then I would be happy to hear it.
From: João Amaro <notifications@github.com>
To: ngallagher/simplexml simplexml@noreply.github.com Cc: Niall Gallagher gallagher_niall@yahoo.com Sent: Friday, 12 February 2016, 0:56 Subject: Re: [simplexml] Fields are not serialized in declaration order on Android (#1)
That means that, in order to force a sequence in the serialization, we have to use that annotation. By other words, when not using this @Order annotation, the serialization order is impredictable, is that it? Because changing the field declaration order won't have any effect on the serialization, as it was expected to be.— Reply to this email directly or view it on GitHub.
Fields are not serialized in declaration order on Android and it seems to vary by Android version. e.g. API 21 seems to have a different order compared to API 22.
According to this javadoc, "By default serialization of fields is done in declaration order." http://simple.sourceforge.net/download/stream/doc/javadoc/
Related StackOverflow question: http://stackoverflow.com/questions/7592752/simple-xml-order-of-elements-not-preserved