改造 – 分析意外的数据types

我正在Android Kotlin项目中使用Retrofit库

并想处理解析意外的数据types。

例如,如果JSON:

{ "boolean": true, "number": "123", "string": "Hello World" } 

数据类将是

 data class Response ( val boolean: Boolean? = null, val number: Int? = null, val string: String? = null ) 

通常情况下,Retrofit将无法解析响应,并且onFailure()将被调用,因为改装不能解析属性number因为它是以字符串forms返回的,并且期望编号,整个对象将无法解析。

我想要的,正常处理请求只是未分析的字段应该是空的。