Skip to content

Instantly share code, notes, and snippets.

@dailymartin
Last active January 9, 2017 04:29
Show Gist options
  • Select an option

  • Save dailymartin/b16336fc4d27505c1fcc9107bb14268c to your computer and use it in GitHub Desktop.

Select an option

Save dailymartin/b16336fc4d27505c1fcc9107bb14268c to your computer and use it in GitHub Desktop.
protected ObjectWriter configureObjectMapper(ObjectMapper jsonObjectMapper) {
jsonObjectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
jsonObjectMapper.setDateFormat(new ISO8601DateFormat());
SimpleFilterProvider filters = new SimpleFilterProvider();
filters.addFilter("validateFilter", SimpleBeanPropertyFilter.serializeAllExcept(new String[]{"valid", "validationErrors"}));
filters.addFilter("pkPassFilter", SimpleBeanPropertyFilter.serializeAllExcept(new String[]{"valid", "validationErrors", "foregroundColorAsObject", "backgroundColorAsObject", "labelColorAsObject", "passThatWasSet"}));
filters.addFilter("barcodeFilter", SimpleBeanPropertyFilter.serializeAllExcept(new String[]{"valid", "validationErrors", "messageEncodingAsString"}));
filters.addFilter("charsetFilter", SimpleBeanPropertyFilter.filterOutAllExcept(new String[]{"name"}));
jsonObjectMapper.setSerializationInclusion(Include.NON_NULL);
jsonObjectMapper.addMixIn(Object.class, PKAbstractSIgningUtil.ValidateFilterMixIn.class);
jsonObjectMapper.addMixIn(PKPass.class, PKAbstractSIgningUtil.PkPassFilterMixIn.class);
jsonObjectMapper.addMixIn(PKBarcode.class, PKAbstractSIgningUtil.BarcodeFilterMixIn.class);
jsonObjectMapper.addMixIn(Charset.class, PKAbstractSIgningUtil.CharsetFilterMixIn.class);
return jsonObjectMapper.writer(filters);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment