Kotlinx Json deserialize Retrofit null json response body

175 Views Asked by At

I am using retrofit with "jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0"

I've got an API call that returns JSON null as "not found" response. I thought that just marking return type as nullable will be enought like this

suspend fun getUserRights(...) : UserRightsApiDto?

But every time I get null JSON value, exception kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the object '{', but had 'EOF' instead JSON input: null is thrown.

How can I fix this and get simple null?

0

There are 0 best solutions below