FasterXML / FasterXML/jackson-dataformats-binary

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

Ouverte
#226 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
avro pr-needed
Langage dominant
Java
Étoiles
347
Forks
156
Merge moyen
3 j 3 h
PR mergées (30 j)
22

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.