aol / cyclops

An advanced, but easy to use, platform for writing functional applications in Java 8.
Apache License 2.0
1.32k stars 136 forks source link

Jackson support for Option seems to not work? #1105

Open OOPMan opened 3 years ago

OOPMan commented 3 years ago

Describe the bug My object mapper is configured as so:

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new CyclopsModule());
objectMapper.registerModule(new Jdk8Module());

I have a class defined as follows:

class A {
   public int someField = 0;
}

class B {
   public Option<A> child = Option.none();
}

When I serialize an instance of B I get JSON like:

{
 "child": null
}

When I attempt to deserialize the JSON produced I get an exception:

Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a Value deserializer for abstract type [reference type, class cyclops.control.Option<my.package.A><[simple type, class my.package.A]>]

To Reproduce Described above

Expected behavior JSON serialization AND deserialization should work...

johnmcclean commented 2 years ago

Deserialization stopped working with later versions of Jackson-databind. 10.4.1 supports the latest versions.