I have a Sample class
data class Sample(
var proxied: Boolean,
var id: String,
var interval: Int,
var parameters: Map<String, String>,
)
below is Sample JSON
{
"proxied": "abc",
"id": 123,
"interval": "test",
"parameters": {
"param1": 1,
"param2": 2
}
}
when I try to deserialize the JSON to Sample, it should throw deserialisation exception since I have given incompatible type values like for id
I have give integer value 123
but it should be a string value. It fails for types Int, Long but not for the String, Boolean, Map
Is there a better way to fail deserialization when json object does'nt map exactly with object fields type?