title: Jackson serialize object as key of map
body: <p>Hi I'm facing problem with serialization of map where key is an custom class.</p>
  
  <pre><code>data class KeyClass(val id: Int, val name: String) {
      fun toJSON() = "\"KeyClass\": {\"id\":$id,\"name\":\"$name\"}"
  }
  </code></pre>
  
  <p>Invocation:</p>
  
  <pre><code> fun method(): Map&lt;KeyClass, List&lt;Something&gt;&gt; = ...
  </code></pre>
  
  <p>My jackson Serializer ofc I'm also adding this as module in objectMapper:</p>
  
  <pre><code>class KeyClassSerializer : JsonSerializer&lt;KeyClass&gt;() {
      override fun serialize(value: KeyClass, gen: JsonGenerator, serializers: SerializerProvider) {
          gen.writeRawValue(value.toJSON())
      }
  
  }
  
  class KeyClassSerializerModule : SimpleModule() {
      init {
          addKeySerializer(KeyClass::class.java, KeyClassSerializer())
      }
  }
  </code></pre>
  
  <p>And JSON I'm receiving is:</p>
  
  <pre><code>"\"KeyClass\": {\"id\":1,\"name\":\"Thomas\"}" : [Something:...]
  </code></pre>
  
  <p>I mean the value of map is serialized correctly but key isn't.</p>