@Override
  public void writeTo(
      Object value,
      Class<?> type,
      Type genericType,
      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream)
      throws IOException {
    ObjectMapper objectMapper = locateMapper(type, mediaType);
    objectMapper.setSerializationInclusion(Inclusion.NON_NULL);

    super.writeTo(value, type, genericType, annotations, mediaType, httpHeaders, entityStream);
  }
예제 #2
0
  @Override
  public void writeTo(
      Object value,
      Class<?> type,
      Type genericType,
      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream)
      throws IOException {
    ObjectMapper mapper = locateMapper(type, mediaType);

    SerializationConfig newSerializerConfig =
        mapper
            .getSerializationConfig()
            .without(Feature.FAIL_ON_EMPTY_BEANS)
            .without(Feature.WRITE_DATES_AS_TIMESTAMPS);

    mapper.setSerializationConfig(newSerializerConfig);
    mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);

    super.writeTo(value, type, genericType, annotations, mediaType, httpHeaders, entityStream);
  }