FasterXML/jackson-module-scala — Issue #11: CaseClassModule is incompatible with Options.
Author: nbauernfeind
Created: 2011-12-14 17:57:52+00:00
State: open

def testJsonWithOption() {
val mapper = new ObjectMapper()
mapper.registerModule(new JacksonModule
with CaseClassModule
with EnumerationModule
with SeqModule
with IterableModule
with TupleModule
with MapModule
with OptionModule
)

val writer = new StringWriter()
mapper.writeValue(writer, Option(42))
println(writer.toString)
}

That throws an exception. It works fine if I remove the CaseClassModule from the mixin. Do you know how I can fix this? Deserialization works fine. I really want a nested Option in my case class.

In fact the CaseClassModule by itself does not work properly with Options.