Skip to content

Commit 725a241

Browse files
authored
Fix #300: Javadoc:java.lang.Number subclasses support @JsonFormat(shape = STRING) (#301)
1 parent e0a5213 commit 725a241

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*<p>
2020
* As of Jackson 2.20, known special handling includes:
2121
*<ul>
22-
* <li>{@link java.util.Date} or {@link java.util.Calendar}: Shape can be {@link Shape#STRING} or {@link Shape#NUMBER};
22+
* <li>{@link java.util.Date} or {@link java.util.Calendar}: Shape can be {@link Shape#STRING} or {@link Shape#NUMBER};
2323
* pattern may contain {@link java.text.SimpleDateFormat}-compatible pattern definition.
2424
* </li>
2525
* <li>{@code java.time.*}: Types in the {@code java.time} package can use
@@ -41,10 +41,14 @@
4141
* if {@link Shape#OBJECT} is used. NOTE: can ONLY be used as class annotation;
4242
* will not work as per-property annotation.
4343
* </li>
44-
* <li>{@link java.lang.Number} subclasses can be serialized as full objects if
45-
* {@link Shape#OBJECT} is used. Otherwise the default behavior of serializing to a
46-
* scalar number value will be preferred. NOTE: can ONLY be used as class annotation;
47-
* will not work as per-property annotation.
44+
* <li>{@link java.lang.Number} subclasses can use {@link Shape#STRING} to serialize to a string.
45+
* This is useful to prevent large numeric values from being rounded to their closest double
46+
* values when deserialized by JSON parsers (for instance <code>JSON.parse()</code> in web
47+
* browsers) that do not support numbers with more than 53 bits of precision.
48+
* <p>
49+
* They can also be serialized to full objects if {@link Shape#OBJECT} is used.
50+
* Otherwise, the default behavior of serializing to a scalar number value will be preferred.
51+
* NOTE: can ONLY be used as class annotation; will not work as per-property annotation.
4852
* </li>
4953
*</ul>
5054
*

0 commit comments

Comments
 (0)