https://kotlinlang.org logo
#ktor
Title
# ktor
j

Jaxon Du

02/15/2020, 7:59 AM
Very new to Ktor and Kotlin. Can I use kotlinx serialization in a ktor rest api server? I installed the ktor plugin in IntelliJ IDEA, when creating a new ktor project, there is no Serialization under “Content Negotiation”, it has GSON, Jackson and ContentNegotiation. I just need to convert between class object and Json. Thought of using serialization as already tested it in KMP mobile app. Is serialization not suitable on server? Or I just need to manually add the dependency to my ktor server project?
t

tjohnn

02/15/2020, 8:11 AM
Yes, you need to manually add it
j

Jaxon Du

02/15/2020, 8:14 AM
Thanks. Just wondering why it’s own serialization package is not in the ktor plugin template. Could be confusing to newbie like me who reach ktor after KMP project.
g

gregorbg

02/15/2020, 8:30 AM
I understand your confusion. But please bear in mind that modularity is one of the core features (and imo also one of the biggest strengths!) of ktor. You want kotlinx serialization? Sure, you can have it - just include the appropriate package. But there's no point in including it if you may use GSON just as well.
Otherwise, this would imply shipping a huge bulk of unused software parts with the core packages.
j

Jaxon Du

02/15/2020, 8:32 AM
Thanks understood