FasterXML / FasterXML/jackson-dataformats-binary

[Avro] can't serialize POJO with extra field (that isn't in the schema)

Đang mở
#226 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
avro pr-needed
Ngôn ngữ chính
Java
Star
347
Fork
156
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
22

Mô tả

My POJO is autogenerated from an avro schema file. There are extra (private) fields in the POJO as a result of the generation.
The mapper doesn't allow me to serialize this POJO with that very schema even though it (the POJO) contains all the necessary fields.

Example:
POJO:
```
class Person {
private String name;
private String unnecessaryField;

// getters, setters and constructors
}
```

Schema:
```
{
"name": "Person",
"type": "record",
"fields": [
{
"name": "name",
"type": "string"
}
]
}
```

Code:
```
Person person = new Person("Jackie", "bla bla");

AvroSchema s = mapper.schemaFrom(personSchemaStr);
byte[] serialized = mapper.writer(s).writeValueAsBytes(person);
```

Exception:
`com.fasterxml.jackson.databind.JsonMappingException: No field named 'unnecessaryField' `

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.