Open 0xg0nz0 opened 9 years ago
Can you send me a small example that reproduces this? I can fix it faster with an example.
If you remove setUseAnnotations(true) it will not work.
JsonSerializerFactory jsonSerializerFactory = new JsonSerializerFactory()
.setAsciiOnly(true)
.setUseAnnotations(true)
.addTypeSerializer(PasswordHolder.class, new AbstractCustomObjectSerializer<PasswordHolder>(PasswordHolder.class) {
@Override
public void serializeObject(JsonSerializerInternal serializer, PasswordHolder instance, CharBuf builder) {
builder.addQuoted(instance.getPassword());
}
})
.usePropertyOnly();
The bug is line 101 in JsonSerializerFactory. It doesn't check if customFieldSerializers is non-null as a condition for creating FieldSerializerUseAnnotationsImpl. So you have to turn on annotations in order to get custom types and field mappings even if you do not use them.