Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect field order during serialisation. #50

Closed
fredcooke opened this issue Jan 25, 2013 · 1 comment
Closed

Respect field order during serialisation. #50

fredcooke opened this issue Jan 25, 2013 · 1 comment

Comments

@fredcooke
Copy link

In order to match existing files from a human perspective, it'd be helpful if the order of elements matched the field order in the classes involved. Either that or provide some other way to choose the ordering, though that seems simplest.

@cowtowncoder
Copy link
Member

Default Jackson settings work here, so that you can force alphabetic ordering, or specific custom order, both with @JsonPropertyOrder (word 'json' is there just for historical reasons).
There is also global setting, MappingFeature.SORT_PROPERTIES_ALPHABETICALLY to make alphabetic ordering the default.

The reason properties are not guaranteed to match declaration order is simply because JDK does not guarantee this ordering: and indeed with JDK 1.7, order in which Methods and Fields are returned by Reflection is arbitrary and unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants