title: How do I convert json into a kotlin object in ktor using content negotiation?
body: <p>I'm new to Ktor, and I'm trying to build a backend that processes login credentials. I'm attempting to use the content negotiation feature to convert JSON into a native Kotlin object, but I keep getting an unsupported media type exception. Here is my code:</p>
  
  <pre><code>fun Application.main() {
      install(CallLogging)
      install(DefaultHeaders)
      install(ContentNegotiation) {
          register(ContentType.Application.Json, GsonConverter())
      }
      routing {
          get("/") {
              call.respondHtml {
                  head {
                      title("Kotlin Webapp")
                      script {
                          type = ScriptType.textJScript
                          src = "main.bundle.js"
                      }
                  }
                  body {
                      div {
                          id = "root"
                      }
                  }
              }
          }
          post("/login") {
              val credentials = call.receive&lt;Credentials&gt;()
              println(credentials)
          }
      }
  }
  
  data class Credentials(val username: String, val password: String)
  </code></pre>
  
  <p>And here is the incoming Json I am trying to convert, which I am sending via XMLHttpRequest:</p>
  
  <pre><code>{"username":"Jamdan2","password":"sometext"}
  </code></pre>
  
  <p>I have searched the web for answers, but could not find what I am doing wrong. Can anybody help?</p>