Ivan Brko
05/07/2020, 12:51 PMDavid Eriksson
05/07/2020, 12:55 PMIvan Brko
05/07/2020, 12:57 PMDavid Eriksson
05/07/2020, 12:57 PMIvan Brko
05/07/2020, 12:59 PMDavid Eriksson
05/07/2020, 1:04 PMapplication.install(ContentNegotiation) {
register(ContentType.Application.Json, SerializationConverter())
}
application.routing {
val model = MyEntity(
777, "Cargo",
listOf(
ChildEntity("Qube", 1),
ChildEntity("Sphere", 2),
ChildEntity(uc, 3)
)
)
get("/") {
call.respond(model)
}'
Ivan Brko
05/07/2020, 1:08 PMinstall(ContentNegotiation) {
json()
register(ContentType.Application.Json, SerializationConverter())
}
Both json() and I call register directly here for Json content. That is OK with Ktor?David Eriksson
05/07/2020, 1:12 PMIvan Brko
05/07/2020, 1:12 PMDavid Eriksson
05/07/2020, 1:12 PMIvan Brko
05/07/2020, 1:13 PMDavid Eriksson
05/07/2020, 1:30 PM// Imagine that MyData is a third-party library class.
// Plugin will try to automatically serialize all constructor properties
// and public vars.
@Serializer(forClass = MyData::class)
object DataSerializer {}