I would like to create some serializers which are aware of some of my spring beans. The best way seems so far to me is extending DefaultSerializerProvider but I could not be sure.
@Component
public class PhotoSerializer extends JsonSerializer<String> {
@Autowired
Service service;
@Override
public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString(service.doIt(value));
}
}
What is the correct way of creating some serializers by Spring?