Skip to content

Deserialize Duration from int-like String (e.g. "3600") #232

Open
@jakub-bochenski

Description

@jakub-bochenski

I think even after #184 and related changes this is still not possible.

Trying to parse a string "3600" into a Duration field results in an exception: "Text cannot be parsed to a Duration"

I've tried adding @JsonFormat("SECONDS") but it seems this only applies to numeric input.

This behaviour is inconsistent with other parts of Jackson:

  • I can convert a int-like String to a regular Long, Integer etc.
  • I can convert a int-like String (e.g. "not_before": "1442340812") to an Instant,
  • I cannot convert an int-like String (e.g. "expires_in": "3600") to a Duration

It would be nice if the handling for @JsonFormat also applied to int-like Strings, not only to actual Numbers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions