ktorm
ktorm copied to clipboard
Wrong json serialization
I have abstract class
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "type"
)
@JsonSubTypes(
JsonSubTypes.Type(value = SomeSettings::class, name = "SomeSettings"),
)
abstract class Settings : Serializable {
val type = this::class.java.simpleName ed
}
data class SomeSettings(var name: String, var value: String) : Settings() {
}
Schema
var settings = json<Settings>("settings").bindTo { it.settings }
Serialization result
{
"settings": {
"type": "SomeSettings"
}
}
name and value fields skipped
Sorry, this issue is about Jackson, not Ktorm.
when using default jackson object mapper(without ktorm module) all ok
val obj = SomeSettings("name", "value")
val str = jacksonObjectMapper().writeValueAsString(obj)
result
{"name":"name","value":"value","type":"SomeSettings"}
OK, let me check.
Any news?
Sorry, cannot reproduce this issue.