FasterXML / FasterXML/jackson-modules-java8

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

Abierto
#232 5 comentarios 1 reacción 0 asignados Ver en GitHub
2.17 pr-welcome
Lenguaje dominante
Java
Estrellas
425
Forks
124
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.