
com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration Maven / Gradle / Ivy
package com.hyperwallet.clientsdk.util;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class HyperwalletJsonConfiguration {
public static final String INCLUSION_FILTER = "inclusion-filter";
private ObjectMapper objectMapper;
private ObjectMapper parsingObjectMapper;
HyperwalletJsonConfiguration() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.objectMapper = new ObjectMapper()
.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
.configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false)
.setDateFormat(dateFormat)
.setSerializationInclusion(Include.ALWAYS);
this.parsingObjectMapper = new ObjectMapper()
.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
.configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false);
}
public ObjectMapper getParser() {
return this.parsingObjectMapper;
}
public ObjectMapper getContext(final Class> type) {
return objectMapper;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy