I’m trying to respond with JSON while following <w...
# ktor
a
I’m trying to respond with JSON while following with these dependencies on my project . However I cannot import
ContentNegotiation
. Am I missing a dependency?
a
How does your
build.gradle
file looks like? The following setup works for me:
Copy code
ext.ktor_version = "1.6.7"

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"

    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    implementation "ch.qos.logback:logback-classic:1.2.3"
    implementation "io.ktor:ktor-serialization:$ktor_version"

    testImplementation "io.ktor:ktor-server-test-host:$ktor_version"
    testImplementation "org.jetbrains.kotlin:kotlin-test"
}
a
@Aleksei Tirman [JB]
implementation "org.jetbrains.kotlin:kotlin-stdlib"
is the only thing i’m missing and it’s not mentioned in the tutorials
a
Btw, the ContentNegotiation is from
io.ktor.features
package.
a
How do i install that please?
a
Do you mean to install the ContentNegotiation plugin?
a
yes it’s not mentioned anywhere in: https://ktor.io/docs/creating-http-apis.html
a
There are links for the template and final projects at the top
a
I tried to do import io.ktor.features.* but the package is not in my classpath
a
Could you please share an archive with your project?
a
My ktor version is 2.0.0-beta-1 if that helps
just followed the wizard
a
Then you should consult docs for 2.0.0.
The documentation you mentioned is for version 1 of Ktor
a
Got it
Thanks
One more thing @Aleksei Tirman [JB] I don’t know which
install
to import. There are a lot of options!
install(ContentNegotiation)
i retyped it and IntelliJ inferred it was from
io.ktor.server.application
👌 1