Hello everyone I have been trying Kotlinx Serializ...
# android
r
Hello everyone I have been trying Kotlinx Serialization in an android project of mine. Is this issue quite common or what? I have a List of String as an object inside my data class. But when I try to parse it, I get stringified array. Following is the data class of my api
Copy code
@Serializable
data class ApiError(
  @SerialName("error") val error: Error
)

@Serializable
data class Error(
  @SerialName("code") val code: Int,
  @SerialName("timestamp") val timestamp: String,
  @SerialName("path") val path: String,
  @SerialName("method") val method: String,
  @SerialName("message") val message: List<String>
)
And this is the parsing logic:
Copy code
private fun ResponseBody?.toApiError(): ApiException {
  return ApiException(
    Json(
      JsonConfiguration(
        ignoreUnknownKeys = true,
        isLenient = true
      )
    ).parse(
      ApiError.serializer(), this?.charStream()
      ?.readText()
      .orEmpty()
    )
  )
}
But when I print the key
message
all I get is
"[User not found.]"
Am I missing here something ? I am using this dependency
com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0
g
So you getting a string instead of array?