public JsonOutputter() { mapper = new ObjectMapper(); mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true); mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); mapper.setPropertyNamingStrategy( PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); }
@Provides @Singleton public ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); mapper.setPropertyNamingStrategy( PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true); mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true); return mapper; }
static { mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz")); mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true); mapper.setPropertyNamingStrategy( PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); }