FasterXML / FasterXML/jackson-dataformats-binary

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

未關閉
#226 9 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
avro pr-needed
主要語言
Java
星號
347
分支
156
平均合併
3 天 3 小時
30 天內合併 PR
22

描述

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' `

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。