Kotlinx.serialization not used for serializing Page<T> and ignores all configuration #28389
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: blocked
An issue that's blocked on an external project change
theme: kotlin
An issue related to Kotlin support
type: enhancement
A general enhancement
Milestone
Affects:
3.0.0-M1
When returning object from a controller method using
@ResponseBody
, and if the returned type isPage<T>
where T is a class marked as@kotlinx.serialization.Serializable
, kotlinx.serialization is not used, it is unclear what exactly is used, and, assuming it's Jackson that is used, all configuration, all annotations and other properties are ignored.I'm using custom InstantSerializer that serializes dates as strings for Kotlinx.serialization.
My POJO is annotated as follows
Returning List or of this pojo returns string for createdAt field:
"createdAt": "2022-03-29T20:19:30.304149Z"
However, returning Page the field is :
"createdAt": 1650109008.203314000
. This breaks FE and introduces inconsistency.I must note that I specifically would like to use strings to serialize dates.
I tried to work around this issue by providing custom Jackson configuration:
None of the above methods worked, and I'm unable to achieve the desired behavior.
My Controller method is as follows:
Condition evaluations report is as follows:
UPDATE:
Registering kotlin module for ObjectMapper:
Allows to apply a workaround by using Jackson configuration alongside kotlinx.serialization configuration (only for annotation, other properties are still ignored)
The bug is still valid because kotlinx.serialization is not used for Page content.
The text was updated successfully, but these errors were encountered: