Skip to content

Support annotation override for WRITE_DATES_AS_TIMESTAMPS #4278

@nhmarujo

Description

@nhmarujo

Is your feature request related to a problem? Please describe.

Not a problem, just lack of flexibility.

Describe the solution you'd like

It is quite normal for someone to create an ObjectMapper and configure it with reasonable defaults that apply to the majority of serializations/deserializations done within a project. For anything that deviates from these defaults, we can annotate and override the defaults. This mechanism is great, since it allows to follow the principle of "convention over configuration", but still allows flexibility when needed.

It seems however that there is no feature in JsonFormat.Feature allowing to override, for an individual case, the value chosen by SerializationFeature.WRITE_DATES_AS_TIMESTAMPS.

This would be great to have, as most of the times people have a particular preference, and that is what they use on their projects, but they need to deal with 3rd parties which JSON contract differs in approach. Would be great to be able to just annotate on those specific objects.

Usage example

Potential use, if that JsonFormat.Feature was added:

@JsonFormat(without = JsonFormat.Feature.WRITE_DATES_AS_TIMESTAMPS)
private Instant timestamp;

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.17Issues planned at earliest for 2.17to-evaluateIssue that has been received but not yet evaluated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions