Support `@JsonFormat` for `String`, numbers, using String.format()
See original GitHub issueSeems like it would be nice to just support formats available via format Strings that String.format()
uses.
Note that existing support for date/time values use different formatting; this should be fine, and if we want to for some reason support something from java.text.Format
it should be possible to use heuristics to determine intended type of format. However that may not be necessary.
Initially we should just support simple types:
java.lang.String
int
,long
,short
,byte
,float
,double
and matching wrapper typesBigDecimal
,BigInteger
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Guide to @JsonFormat in Jackson - Baeldung
A quick and practical guide to the @JsonFormat annotation in Jackson. ... STRING, pattern = "yyyy-MM-dd") public Date getCurrentDate() ...
Read more >JsonFormat writes string even with NUMBER shape for a ...
NumberSerializer respects @JsonFormat annotation and if you set STRING shape it will produce JSON String instead of JSON Number .
Read more >JsonFormat.Shape (Jackson-annotations 2.10.0 API)
Value that indicates that integer number type should be used (and not NUMBER_FLOAT ). STRING. public static final JsonFormat.Shape STRING. Value that indicates ......
Read more >string — Understanding JSON Schema 2020-12 documentation
The format keyword allows for basic semantic identification of certain kinds of string values that are commonly used.
Read more >JSON.stringify() - JavaScript - MDN Web Docs
A string or number that's used to insert white space (including indentation, line break characters, etc.) into the output JSON string for readability...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @cowtowncoder , does this issue mean supporting the use-case below, where
@JsonFormat
is used to contextualize the serialization?And it should be serialized as follow:
I understand that it should support other numeric types and different locales as well. I would like to contribute on this one. If you could give me some hints about where to get started, that will be great.
Hope this feature can be implement, spring framework has a
@NumberFormat
annotation provide similar feature!