JSonSerializerWithAccessFilter - idea for parallel structure with deserializer

This commit is contained in:
Michael Hoennig 2019-04-23 06:28:36 +02:00
parent 741e91bb78
commit 90316a262b

View File

@ -20,7 +20,9 @@ public class JSonSerializerWithAccessFilter extends JsonSerializer<Object> {
public void serialize(final Object dto, final JsonGenerator jsonGenerator, public void serialize(final Object dto, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider) throws IOException { final SerializerProvider serializerProvider) throws IOException {
// TODO: move the implementation to an (if necessary, inner) class // TODO: Move the implementation to an (if necessary, inner) class, or maybe better
// expose just the inner implementation from an explicit @JsonCompontent
// as it's necessary for the deserializers anyway.
jsonGenerator.writeStartObject(); jsonGenerator.writeStartObject();
for (Field prop : dto.getClass().getDeclaredFields()) { for (Field prop : dto.getClass().getDeclaredFields()) {
toJSon(dto, jsonGenerator, prop); toJSon(dto, jsonGenerator, prop);