jackson-module-scala icon indicating copy to clipboard operation
jackson-module-scala copied to clipboard

investigate Map serialization test that fails with Scala 3

Open pjfanning opened this issue 4 years ago • 1 comments

Passes with Scala 2.

  • https://github.com/FasterXML/jackson-module-scala/blob/master/src/test/scala-2.%2B/com/fasterxml/jackson/module/scala/ser/MapScala2SerializerTest.scala

pjfanning avatar Jul 31 '21 19:07 pjfanning

The issue appears to relate to the anonymous class generated for the wrapper val.

    val wrapper = new {
      val map = Map.apply[String, MapValueBase]("Double" -> MapValueDouble(1.0), "String" -> MapValueString("word"))
    }

If I declare a case class that wraps the map, the test passes.

The issue appears to be that when the anonymous class is used then the Java annotations on MapValueBase are not picked up by the jackson code (that uses Java reflection to work out the type information).

pjfanning avatar Sep 24 '21 14:09 pjfanning