eclipse-ee4j / eclipse-ee4j/yasson
Interpretation of the "ANY" PropertyOrderStrategy
- Dominant language
- Java
- Stars
- 218
- Forks
- 109
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Description
**Is your feature request related to a problem? Please describe.**
I'm always frustrated with the Yasson implementation of the ANY serialization order. The spec says ANY means "the order of properties is not guaranteed to retain any order." The Yasson interpretation of that is correct, but NOT user friendly - the serialized json result has "random" (HashMap) property order, which is not as sensible to the user as "same order as the properties fields or getters appear in the Java class". Although the spec says ANY means no guarantee, having it in a sensible order does not violate the spec.
**Describe the solution you'd like**
When the PropertyOrderStrategy is ANY, then the JSON serialization should preserve the same order the property fields (or getters) as they appear in the Java source class.
**Describe alternatives you've considered**
Alternatively, the Yasson impl could provide an additional custom order to the spec e.g. SOURCE, meaning the serialization (or even the deserialization) should be in the same order as the property fields/getters/setters appear in the source Java class (or source JSON for deserialization).
Contributor guide
Research direction
Start by reviewing Yasson's handling of PropertyOrderStrategy.ANY and how it discovers Java fields, getters, and setters. Compare the current behavior with the requested source-class order, then define tests that verify serialization preserves that order while remaining compliant with the spec.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100