retrofit
retrofit copied to clipboard
support return a List that its' element may be null
it seems no support the return a List that its' element may be null ,like below example. The function prototype
interface ApiService {
suspend fun funA(
@Body ids: List<Long>
): Result<BaseResponse<List<ADTO?>>>
}
The Api Provide like below
fun provideApiService(configure: AppConfigure, okHttpClient: OkHttpClient): ApiService {
val appJson = Json {
ignoreUnknownKeys = true
explicitNulls = true
}
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl(configure.baseApiUrl)
.addConverterFactory(appJson.asConverterFactory("application/json;charset=UTF-8".toMediaType()))
.addCallAdapterFactory(ResultCallAdapterFactory.create())
.build().create(ApiService::class.java)
}
The packet is {"code":0,"data":[{"createTime":"2022-11-23 15:28:29","faceId":123,"faceUrl":"","feature":"ABC"},null,null]}
it is failed, because the null element , how can i to solve this problem? tks