vavr-io / vavr-jackson

Jackson datatype module for Vavr
Apache License 2.0
97 stars 35 forks source link

Can not deserialize explicit Option.Some or Option.None #165

Closed chisui closed 4 years ago

chisui commented 4 years ago

If a json property has the the Option.Some or Option.None it can not be deserialized:

    static class MyType {
        @JsonProperty Option<String> p;
    }
    static class MyBrokenType {
        @JsonProperty Option.Some<String> p;
    }

    public static void main(String[] args) {
        ObjectMapper om = new ObjectMapper().registerModule(new VavrModule());
        System.out.println(om.canDeserialize(om.constructType(MyType.class))); // true as expected
        System.out.println(om.canDeserialize(om.constructType(MyBrokenType.class))); // false but true expected
    }

Either.Left and Either.Right work fine though.

mincong-h commented 4 years ago

Thanks for reporting this @chisui ! The fix is in progress https://github.com/vavr-io/vavr-jackson/pull/166. Meanwhile, I suggest not using the deprecated classes Option.{Some,None}, they are meant to be internal classes.

chisui commented 4 years ago

In the latest non alpha release 0.10.3 Option.Some and Option.None are not deprecated.

mincong-h commented 4 years ago

Ah, yes, you're right. Thanks for pointing out 👍 You make me think that we should back-port the solution to 0.10.x as well. This is done now as 07616da9f2bbb3c7eb00168a32c582a304f80e65.