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

jackson-modules.mddocs/

Jackson Modules

Dropwizard Jackson provides several custom Jackson modules that extend serialization capabilities for specific types and use cases commonly found in Dropwizard applications.

CaffeineModule

Jackson module that provides serialization and deserialization support for Caffeine cache specifications.

public class CaffeineModule extends Module {
    public String getModuleName() // Returns "CaffeineModule"
    public Version version()
    public void setupModule(SetupContext context)
}

Supported Types:

  • com.github.benmanes.caffeine.cache.CaffeineSpec

Serialization Behavior:

  • Serializes CaffeineSpec objects to their parseable string representation
  • Deserializes string values back to CaffeineSpec objects
  • Handles "off" and "disabled" as special values for disabled caching

Usage Example:

ObjectMapper mapper = Jackson.newObjectMapper(); // CaffeineModule automatically included

CaffeineSpec spec = CaffeineSpec.parse("maximumSize=1000,expireAfterWrite=30s");
String json = mapper.writeValueAsString(spec);
// Result: "maximumSize=1000,expireAfterWrite=30s"

CaffeineSpec deserialized = mapper.readValue(json, CaffeineSpec.class);

FuzzyEnumModule

Jackson module that provides permissive enum deserialization, handling common formatting variations.

public class FuzzyEnumModule extends Module {
    public String getModuleName() // Returns "permissive-enums"
    public Version version()
    public void setupModule(SetupContext context)
}

Deserialization Features:

  • Case Insensitive: Matches enum values regardless of case
  • Whitespace Handling: Strips leading and trailing whitespace
  • Character Normalization: Converts dashes and periods to underscores
  • Flexible Matching: Uses Enums.fromStringFuzzy() utility for permissive matching
  • Error Handling: Provides clear error messages listing accepted values when deserialization fails

Behavior Conditions:

  • Only applies when no @JsonCreator annotation is present
  • Disabled when READ_ENUMS_USING_TO_STRING feature is enabled
  • Disabled when READ_UNKNOWN_ENUM_VALUES_AS_NULL feature is enabled
  • Disabled when READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE feature is enabled
  • Disabled when enum fields have Jackson annotations from com.fasterxml.jackson.annotation package

Usage Example:

public enum Status {
    ACTIVE, INACTIVE, PENDING
}

ObjectMapper mapper = Jackson.newObjectMapper(); // FuzzyEnumModule automatically included

// All of these will deserialize to Status.ACTIVE:
Status active1 = mapper.readValue("\"active\"", Status.class);
Status active2 = mapper.readValue("\"ACTIVE\"", Status.class);
Status active3 = mapper.readValue("\" active \"", Status.class);
Status active4 = mapper.readValue("\"act-ive\"", Status.class);

GuavaExtrasModule

Jackson module that provides serialization and deserialization support for Guava cache builder specifications.

public class GuavaExtrasModule extends Module {
    public String getModuleName() // Returns "guava-extras"
    public Version version()
    public void setupModule(SetupContext context)
}

Supported Types:

  • com.google.common.cache.CacheBuilderSpec

Serialization Behavior:

  • Serializes CacheBuilderSpec objects to their parseable string representation
  • Deserializes string values back to CacheBuilderSpec objects
  • Handles "off" and "disabled" as special values for disabled caching

Usage Example:

ObjectMapper mapper = Jackson.newObjectMapper(); // GuavaExtrasModule automatically included

CacheBuilderSpec spec = CacheBuilderSpec.parse("maximumSize=500,expireAfterAccess=10m");
String json = mapper.writeValueAsString(spec);
// Result: "maximumSize=500,expireAfterAccess=10m"

CacheBuilderSpec deserialized = mapper.readValue(json, CacheBuilderSpec.class);

// Special handling for disabled caches
CacheBuilderSpec disabled = mapper.readValue("\"disabled\"", CacheBuilderSpec.class);
// Results in CacheBuilderSpec.disableCaching()

Module Registration

All modules are automatically registered when using Jackson factory methods:

ObjectMapper mapper = Jackson.newObjectMapper();
// All three modules (CaffeineModule, FuzzyEnumModule, GuavaExtrasModule) are pre-registered

ObjectMapper minimal = Jackson.newMinimalObjectMapper();
// Only GuavaModule is registered (not the custom Dropwizard modules)

Integration with Standard Modules

The custom modules work alongside standard Jackson modules that are also automatically registered:

  • GuavaModule: Basic Guava collections support
  • ParameterNamesModule: Constructor parameter name preservation
  • Jdk8Module: Java 8 Optional and Stream support
  • JavaTimeModule: JSR-310 time types (LocalDate, Instant, etc.)
  • Performance Modules: Afterburner or Blackbird for optimization

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