You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,8 @@ public class PostDataHandler implements RequestHandler {
44
44
byte[] body = request.bytes();
45
45
// Loose structural view (Map / List / boxed primitives), produced by the registered TypeMapper.
46
46
Object parsed = request.parsed();
47
-
// Or, when the JSON mapper is Jackson (a TypedTypeMapper), get a typed POJO directly.
47
+
// Or get a typed POJO directly (works with the Gson and Jackson built-ins; both implement
48
+
// TypedTypeMapper).
48
49
MyDto dto = request.asPojo(MyDto.class);
49
50
// Path parameters, query parameters, and headers are also available.
50
51
String id = request.pathParam("id");
@@ -117,8 +118,9 @@ public class YourServerLauncher {
117
118
118
119
The library ships an internal `GsonJsonMapper` that is auto-registered for `application/json` when Gson is on the classpath and no user-supplied JSON mapper has been registered. It:
119
120
120
-
- Returns JSON integers as `Long` and fractional numbers as `Double`.
- Returns JSON integers as `Long` and fractional numbers as `Double` for the loose `request.parsed()` view.
122
+
- For `request.asPojo(MyDto.class)`, delegates to Gson — the target type's fields determine the Java types (`int`, `long`, `Instant`, etc.).
123
+
- Round-trips JSR-310 types (`Instant`, `OffsetDateTime`, `ZonedDateTime`, `LocalDateTime`, `LocalDate`, `LocalTime`) as their ISO-8601 string form.
122
124
123
125
For Jackson, the library ships a `JacksonJsonTypeMapper` adapter that wraps an `ObjectMapper` you configure (modules, naming strategy, JSR-310, date formats — all your call):
0 commit comments