FasterXML / FasterXML/jackson-modules-java8

Cannot read Optionals written with StdTypeResolverBuilder

Aperta
#86 6 commenti 1 reazione 0 assegnatari Vedi su GitHub
2.19 pr-welcome
Lingua principale
Java
Stelle
425
Fork
124
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

The following test fails on Jackson 2.9.7 and passes on 2.8.11:
```
@Test
public void test() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultTyping(
new StdTypeResolverBuilder()
.init(JsonTypeInfo.Id.CLASS, null)
.inclusion(JsonTypeInfo.As.WRAPPER_OBJECT)
);
mapper.registerModule(new Jdk8Module());
String json = mapper.writeValueAsString(new Foo(Optional.of(1)));
System.out.println(json);
mapper.readValue(json, Foo.class);
}

public static class Foo {
private Optional bar;

public Foo() {
}

public Foo(Optional bar) {
this.bar = bar;
}

public Optional getBar() {
return bar;
}

public void setBar(Optional bar) {
this.bar = bar;
}
}
```
Complete runnable project with this test-case can be found on https://github.com/isopov/jackson-optional-test

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.