Skip to content

Change semantics of @JsonPropertyOrder(alphabetic) to only count true value #840

@cowtowncoder

Description

@cowtowncoder

(for background, see: FasterXML/jackson-dataformat-csv#74)

One problem with @JsonPropertyOrder, is that since Java Annotations can not take null values (a clear flaw in Annotation system in Java), or any other optionality, annotation like:

@JsonPropertyOrder(value={ "a", "b" })

will actually mean following, due to (need for) value defaulting:

@JsonPropertyOrder(value={ "a", "b" }, alphabetic=false)

Now: this is ok in general, except for one thing: there is global feature to enable alphabetic sorting, and thus annotation usage may accidentally turn off this sorting. That in turn causes problems for dataformats like CSV and Avro, where position/order of values is critically important.

But since it seems unlikely that setting of alphabetic=false would be of any use to anyone (some other settings might be useful for sorting, but "default" of "whatever JDK offers" is not), it's better to consider such setting to mean "use defaults".

So let's change this for 2.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions