private String prepareJsonForUpdate(Organization clientTenant) { ObjectMapper mapper = new ObjectMapper(); SerializationConfig serializationConfig = mapper.getSerializationConfig(); serializationConfig = serializationConfig.withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(); mapper.setSerializationConfig(serializationConfig); mapper.setAnnotationIntrospector(introspector); String json; try { json = mapper.writeValueAsString(clientTenant); } catch (IOException e) { log.error("Cannot marshal organization object."); throw new JSClientException("Cannot marshal organization object."); } return json; }
@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); }