Provides comprehensive Jackson JSON processing support for Dropwizard applications with pre-configured ObjectMapper instances and essential modules.
—
The Jackson utility class provides factory methods for creating pre-configured ObjectMapper instances optimized for Dropwizard applications.
Creates a new ObjectMapper with comprehensive Dropwizard configuration including all modules and optimizations.
public static ObjectMapper newObjectMapper()Returns: Fully configured ObjectMapper instance
Configuration includes:
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);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 useReturns: 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);Creates a minimal ObjectMapper with only essential Dropwizard configuration for less aggressive processing.
public static ObjectMapper newMinimalObjectMapper()Returns: Minimally configured ObjectMapper instance
Configuration includes:
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);The factory methods automatically discover and register Jackson modules available on the classpath:
@JsonSnakeCase annotationInstall with Tessl CLI
npx tessl i tessl/maven-io-dropwizard--dropwizard-jackson