Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
@Retention(CLASS) @Target({FIELD})
public @interface JsonFormat
Picks the JSON shape a date or number field is written in.
- A
java.util.Dateis milliseconds since the epoch by default. WithShape.STRINGit is an ISO-8601 instant in UTC,2026-10-25T08:30:00.000Z. - A number is a JSON number by default. With
Shape.STRINGit is the same digits in quotes – what a JavaScript client needs for alongpast 2^53, which its numbers cannot hold exactly.
Reading accepts either shape whatever the annotation says, so a field can change its format without breaking the clients that still send the old one. Any other combination is refused by the build.
Nested types
enum JsonFormat.Shape | A JSON shape for a scalar value. |
Methods
public abstract JsonFormat.Shape value() | The shape the value is written in. |
Method details
value
public abstract JsonFormat.Shape value()The shape the value is written in.