FasterXML / FasterXML/jackson-modules-java8

Cannot read Optionals written with StdTypeResolverBuilder

Đang mở
#86 6 bình luận 1 reaction 0 người được giao Xem trên GitHub
2.19 pr-welcome
Ngôn ngữ chính
Java
Star
425
Fork
124
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.