CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-dropwizard--dropwizard-jackson

Provides comprehensive Jackson JSON processing support for Dropwizard applications with pre-configured ObjectMapper instances and essential modules.

Pending
Overview
Eval results
Files

object-mapper-factory.mddocs/

ObjectMapper Factory

The Jackson utility class provides factory methods for creating pre-configured ObjectMapper instances optimized for Dropwizard applications.

Static Factory Methods

newObjectMapper()

Creates a new ObjectMapper with comprehensive Dropwizard configuration including all modules and optimizations.

public static ObjectMapper newObjectMapper()

Returns: Fully configured ObjectMapper instance

Configuration includes:

  • Guava module for Guava collections support
  • GuavaExtrasModule for CacheBuilderSpec serialization
  • CaffeineModule for CaffeineSpec serialization
  • FuzzyEnumModule for permissive enum deserialization
  • ParameterNamesModule for constructor parameter name preservation
  • Jdk8Module for Optional and Stream support
  • JavaTimeModule for JSR-310 time types
  • Performance module (Afterburner or Blackbird)
  • AnnotationSensitivePropertyNamingStrategy for snake_case support
  • DiscoverableSubtypeResolver for polymorphic configurations
  • Disables FAIL_ON_UNKNOWN_PROPERTIES

Usage Example:

ObjectMapper mapper = Jackson.newObjectMapper();

// The mapper is now ready for production use with all optimizations
String json = mapper.writeValueAsString(complexObject);
MyClass result = mapper.readValue(json, MyClass.class);

newObjectMapper(JsonFactory)

Creates a new ObjectMapper with a custom JsonFactory and full Dropwizard configuration.

public static ObjectMapper newObjectMapper(JsonFactory jsonFactory)

Parameters:

  • jsonFactory (JsonFactory, nullable): Custom JsonFactory instance to use

Returns: Fully configured ObjectMapper instance using the provided JsonFactory

Usage Example:

// Create ObjectMapper with custom JsonFactory for YAML processing
YAMLFactory yamlFactory = new YAMLFactory();
ObjectMapper yamlMapper = Jackson.newObjectMapper(yamlFactory);

// Or with custom JSON factory settings
JsonFactory customFactory = new JsonFactory()
    .enable(JsonParser.Feature.ALLOW_COMMENTS);
ObjectMapper mapper = Jackson.newObjectMapper(customFactory);

newMinimalObjectMapper()

Creates a minimal ObjectMapper with only essential Dropwizard configuration for less aggressive processing.

public static ObjectMapper newMinimalObjectMapper()

Returns: Minimally configured ObjectMapper instance

Configuration includes:

  • GuavaModule for basic Guava collections support
  • DiscoverableSubtypeResolver for polymorphic configurations
  • Disables FAIL_ON_UNKNOWN_PROPERTIES

Usage Example:

// Use when the full configuration is too aggressive for your use case
ObjectMapper minimalMapper = Jackson.newMinimalObjectMapper();

// Still provides essential Dropwizard functionality
String json = minimalMapper.writeValueAsString(simpleObject);

Configuration Details

Automatic Module Discovery

The factory methods automatically discover and register Jackson modules available on the classpath:

  • Afterburner Module: High-performance bytecode generation (preferred)
  • Blackbird Module: Fallback performance enhancement when Afterburner unavailable

Property Handling

  • Unknown Properties: Ignored by default (FAIL_ON_UNKNOWN_PROPERTIES disabled)
  • Naming Strategy: Supports both camelCase and snake_case via @JsonSnakeCase annotation
  • Parameter Names: Preserved in JSON for constructor parameters

Type Support

  • Java 8 Types: Optional, Stream, LocalDate, LocalDateTime, Instant, etc.
  • Guava Collections: ImmutableList, ImmutableMap, Multimap, etc.
  • Cache Specifications: CaffeineSpec and CacheBuilderSpec serialization
  • Enums: Fuzzy matching (case-insensitive, handles dashes/periods)

Install with Tessl CLI

npx tessl i tessl/maven-io-dropwizard--dropwizard-jackson

docs

index.md

jackson-modules.md

object-mapper-factory.md

property-naming.md

subtype-discovery.md

tile.json