hi, how can I make data class with empty arrays encode to empty json arrays?
val jsonMapper = Json {
prettyPrint = true
encodeDefaults = true
coerceInputValues = true
}
val inputPet = Pet(
name = petName,
tags = emptyList(),
photoUrls = emptyList(),
status = petStatus
)
val inputPetJson = jsonMapper.encodeToString(inputPet)
Actual :{"name":"blaaaah","status":"available"}
Expected:{"name":"blaaaah","photoUrls":[],"tags":[],"status":"available"}
I’ve tried various combinations of encodeDefaults and coerceInputValues. The problem is that
Pet
has other fields that default to null. I don’t want to include those.