FasterXML / FasterXML/jackson-modules-java8

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

未關閉
#232 5 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
2.17 pr-welcome
主要語言
Java
星號
425
分支
124
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。