Coercion of primitive types during deserialization #1121
Unanswered
krystofrezac
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I've encountered an issue where primitive types are being automatically converted into other primitive types during deserialization. Specifically, I would like to prevent this behavior and enforce that deserialization only succeeds when the input JSON type matches exactly the type declared in my DTO.
Example
Given the following DTO and deserialization code:
Current Behavior:
123is deserialized into thestringproperty.1is deserialized into thebooleanproperty astrue.Configuration
I have the following settings in
application.properties:Question
Is there a way to disable this automatic primitive type conversion, so that deserialization fails if the JSON value type does not exactly match the DTO property type (e.g., number to string, number to boolean)? Ideally, I want an error to be thrown if the types don't match.
Thank you in advance for any guidance or suggestions!
Beta Was this translation helpful? Give feedback.
All reactions