Env
Kotlin + Retrofit 2 + fastjson 1.1.68.android
Retrofit converter
https://github.com/alibaba/fastjson/blob/master/src/main/java/com/alibaba/fastjson/support/retrofit/Retrofit2ConverterFactory.java
Raw
{"Status":200,"ErrCode":401,"ErrMsg":"您的登录已过期,请重新登录","Data":null,"TotalCount":0}
Data model
@Keep
data class ResultModel<T>(val Status: Int, val ErrCode: Int, val ErrMsg : String = "",
val Data: T, val TotalCount : Int) {
fun isSuccessful() = ErrCode == 0
}
@Keep
@Parcelize
data class Product(/**Not important so I omitted it**/) : Parcelable
Usage
The T
I passed into is ResultModel<Array<Product>>
Problem
The Data
was expected to get a Product
array, but sometimes it may be null
. Fastjson will run into an exception while Data
is null rather than an empty null. I tried to switch to Gson converter and it solved my problem with the following expected result:
1条答案
按热度按时间8nuwlpux1#
please provide exception stack detail information