I've written my CustomJsonSerializer and I would like it to automatically serialize all fields that are annotated using @JsonProperty so I would only left serializing the ones which are not annotated and need "special care".
For example: I have the Pojo
class Player {
@JsonProperty(user_id)
private long userId;
private byte[] history;
}
My custom Serializer:
public class JsonPlayerSerializer extends JsonSerializer<Player> {
@Override
public void serialize(Player player, JsonGenerator gen,
SerializerProvider provider) throws IOException, JsonProcessingException {
// I would like to add some code here that automatically would add all annotated fields.
gen.writeObjectField("history_moves", new JsonObject().put("$binary", myMoves));
}
}