title: Serialize a Map<LocalDate, Object> with Ktor and kotlinx.serialization
body: <p>Here's a Ktor route that returns a map of LocalDates:</p>
  
  <pre><code>route {
     get {
         val map = mapOf(LocalDate.now() to "test")
         call.respond(map)
     }
  }
  </code></pre>
  
  <p>LocalDate is not serializable, however:</p>
  
  <pre><code>kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class LocalDate. For generic classes, such as lists, please provide serializer explicitly.
  </code></pre>
  
  <p>I've built my own serializer:</p>
  
  <pre><code>@Serializer(forClass = LocalDate::class)
  object LocalDateSerializer : KSerializer&lt;LocalDate&gt; {
      override fun serialize(encoder: Encoder, value: LocalDate) {
          encoder.encodeString(value.toString())
      }
  
      override fun deserialize(decoder: Decoder): LocalDate {
          return LocalDate.parse(decoder.decodeString())
      }
  }
  </code></pre>
  
  <p>I can use this serializer in a data class, e.g. <code>data class Foo(@Serializable(with=LocalDateSerializer::class)date: LocalDate</code>. But I don't know how to get it work with my map.</p>
  
  <p>I've tried a couple different annotations:</p>
  
  <pre><code>val map: Map&lt;@ContextualSerialization LocalDate, String&gt; = mapOf(LocalDate.now() to "test")
  // OR
  val map: Map&lt;@Serializable(with=LocalDateSerializer::class) LocalDate, String&gt; = mapOf(LocalDate.now() to "test")
  </code></pre>
  
  <p>And I've tried registering it with Ktor:</p>
  
  <pre><code>install(ContentNegotiation) {
      json(module = serializersModuleOf(LocalDate::class, LocalDateSerializer))
  }
  </code></pre>
  
  <p>No matter what I try, I get the same <code>SerializationException</code> as above.</p>
  
  <p>How can I apply my serializer automatically when kotlinx.serialization tries to parse a LocalDate? OR how can I suggest a serializer when Ktor tries to serialize my map?</p>