Search in sources :

Example 1 with JsonNaming

use of com.fasterxml.jackson.databind.annotation.JsonNaming in project SchemaCrawler by schemacrawler.

the class BaseJacksonSerializedCatalog method newConfiguredObjectMapper.

private ObjectMapper newConfiguredObjectMapper() {
    @JsonIgnoreProperties({ "parent", "referenced-column", "exported-foreign-keys", "imported-foreign-keys" })
    @JsonPropertyOrder(value = { "@uuid", "name", "short-name", "full-name", "crawl-info", "schema-crawler-info", "jvm-system-info", "operating-system-info", "database-info", "jdbc-driver-info", "schemas", "system-column-data-types", "column-data-types", "all-table-columns" }, alphabetic = true)
    @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@uuid")
    @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
    @JsonFilter("ignore-getter-errors-filter")
    class JacksonAnnotationMixIn {
    }
    final FilterProvider filters = new SimpleFilterProvider().addFilter("ignore-getter-errors-filter", (PropertyFilter) new IgnoreExceptionBeanPropertyFilter());
    final ObjectMapper mapper = newObjectMapper();
    mapper.enable(ORDER_MAP_ENTRIES_BY_KEYS, INDENT_OUTPUT, USE_EQUALITY_FOR_OBJECT_ID, WRITE_ENUMS_USING_TO_STRING);
    mapper.registerModule(new JavaTimeModule());
    mapper.addMixIn(Object.class, JacksonAnnotationMixIn.class);
    mapper.setFilterProvider(filters);
    return mapper;
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JsonIdentityInfo(com.fasterxml.jackson.annotation.JsonIdentityInfo) ObjectIdGenerators(com.fasterxml.jackson.annotation.ObjectIdGenerators) JsonFilter(com.fasterxml.jackson.annotation.JsonFilter) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JsonPropertyOrder(com.fasterxml.jackson.annotation.JsonPropertyOrder) JsonNaming(com.fasterxml.jackson.databind.annotation.JsonNaming) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties)

Example 2 with JsonNaming

use of com.fasterxml.jackson.databind.annotation.JsonNaming in project SchemaCrawler by schemacrawler.

the class BaseLintReportJacksonBuilder method newConfiguredObjectMapper.

private ObjectMapper newConfiguredObjectMapper() {
    @JsonPropertyOrder(alphabetic = true)
    @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
    abstract class JacksonAnnotationMixIn {

        @JsonIgnore
        public Object value;

        @JsonProperty("value")
        public abstract Object getValueAsString();
    }
    final JavaTimeModule timeModule = new JavaTimeModule();
    timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    final ObjectMapper mapper = newObjectMapper();
    mapper.enable(ORDER_MAP_ENTRIES_BY_KEYS, INDENT_OUTPUT, USE_EQUALITY_FOR_OBJECT_ID, WRITE_ENUMS_USING_TO_STRING);
    mapper.addMixIn(Object.class, JacksonAnnotationMixIn.class);
    mapper.addMixIn(Lint.class, JacksonAnnotationMixIn.class);
    mapper.registerModule(timeModule);
    return mapper;
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JsonPropertyOrder(com.fasterxml.jackson.annotation.JsonPropertyOrder) JsonNaming(com.fasterxml.jackson.databind.annotation.JsonNaming) LocalDateTimeSerializer(com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonNaming (com.fasterxml.jackson.databind.annotation.JsonNaming)2 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)2 JsonFilter (com.fasterxml.jackson.annotation.JsonFilter)1 JsonIdentityInfo (com.fasterxml.jackson.annotation.JsonIdentityInfo)1 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 ObjectIdGenerators (com.fasterxml.jackson.annotation.ObjectIdGenerators)1 FilterProvider (com.fasterxml.jackson.databind.ser.FilterProvider)1 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)1 LocalDateTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer)1