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
{{ message }}
Repository navigation
Commit 9cf7af8
Browse filesBrowse the repository at this point in the historyBrowse files
feat: Add Jackson3JsonTypeMapper and rename Jackson v2 adapter (#61)
Renames JacksonJsonTypeMapper to Jackson2JsonTypeMapper and introduces
Jackson3JsonTypeMapper backed by tools.jackson.databind (Jackson 3.1.3).
Both adapters ship side-by-side as optional dependencies; consumers pick
whichever matches their classpath. Jackson 3 made I/O exceptions
unchecked, so the v3 adapter no longer wraps them in UncheckedIOException.
Copy file name to clipboardExpand all lines: README.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ It is designed to be simple to use while providing the essential features needed
24
24
- An OpenAPI 3.1.x specification (`openapi.json` or `openapi.yaml`).
25
25
- For `application/json` request/response bodies, either:
26
26
- Gson on the classpath — auto-registered via the built-in `GsonJsonMapper` (integer-preserving, JSR-310 written as ISO-8601), or
27
-
- Jackson via the built-in `JacksonJsonTypeMapper(ObjectMapper)`adapter (caller supplies a configured `ObjectMapper`), or
27
+
- Jackson via the built-in adapters — `Jackson2JsonTypeMapper(ObjectMapper)`for Jackson 2.x (`com.fasterxml.jackson.*`) or `Jackson3JsonTypeMapper(ObjectMapper)` for Jackson 3.x (`tools.jackson.*`). Caller supplies a configured `ObjectMapper`; the two adapters use disjoint package roots and can coexist on the same classpath.
28
28
- any other `TypeMapper` you register via `Builder.jsonMapper(mapper)` (shortcut for `bodyMapper("application/json", mapper)`).
29
29
- Built-in mappers for `application/x-www-form-urlencoded` and `text/plain` need no configuration. Any other media type (`application/xml`, `application/cbor`, etc.) requires registering its own `TypeMapper`.
30
30
@@ -123,20 +123,42 @@ The library ships an internal `GsonJsonMapper` that is auto-registered for `appl
123
123
- For `request.asPojo(MyDto.class)`, delegates to Gson — the target type's fields determine the Java types (`int`, `long`, `Instant`, etc.).
124
124
- Round-trips JSR-310 types (`Instant`, `OffsetDateTime`, `ZonedDateTime`, `LocalDateTime`, `LocalDate`, `LocalTime`) as their ISO-8601 string form.
125
125
126
-
For Jackson, the library ships a `JacksonJsonTypeMapper` adapter that wraps an `ObjectMapper` you configure (modules, naming strategy, JSR-310, date formats — all your call):
126
+
For Jackson, the library ships two adapters that wrap an `ObjectMapper` you configure (modules, naming strategy, JSR-310, date formats — all your call). Pick the one that matches your Jackson major:
127
+
128
+
```java
129
+
// Jackson 2.x (group: com.fasterxml.jackson.core)
Jackson 3 made all I/O exceptions unchecked (`tools.jackson.core.JacksonException extends RuntimeException`), so `Jackson3JsonTypeMapper` propagates read/write failures as-is. `Jackson2JsonTypeMapper` wraps Jackson 2's checked `IOException` in `UncheckedIOException`.
161
+
140
162
The same shape applies to any custom mapper — implement `TypeMapper` (and optionally `TypedTypeMapper` if you can deserialise directly into a target type, so handlers can call `request.asPojo(MyDto.class)`).
141
163
142
164
If neither Gson is on the classpath nor any `application/json` mapper is registered, `build()` throws `IllegalStateException`.
0 commit comments