Part of
problem4j
package of libraries.
Jackson integration module for problem4j-core
. Provides easy support for serializing and
deserializing the Problem
model using Jackson's ObjectMapper
.
- ✅ Seamless JSON serialization of
Problem
objects - ✅ Accurate deserialization into immutable
Problem
instances - ✅ Compatible with standard Jackson
ObjectMapper
- ✅ Pluggable via Jackson’s
Module
system - ✅ Lightweight, with no external dependencies beyond Jackson and
problem4j-core
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new ProblemModule());
Problem problem =
Problem.builder()
.type("https://example.com/errors/invalid-request")
.title("Invalid Request")
.status(400)
.detail("not a valid json")
.instance("https://example.com/instances/1234")
.build();
String json = mapper.writeValueAsString(problem);
Problem parsed = mapper.readValue(json, Problem.class);
This library is available through Jitpack repository. Add it along with repository in your dependency manager.
// build.gradle
repositories {
// ...
maven { url = uri("https://jitpack.io") }
}
dependencies {
// ...
implementation("com.github.malczuuu:problem4j-core:<problem4j-core-version>")
implementation("com.github.malczuuu:problem4j-jackson:<problem4j-jackson-version>")
}