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
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.malczuuu.problem4j.core.Problem;
import io.github.malczuuu.problem4j.jackson.ProblemModule;
public class ExampleClass {
public void method() {
ObjectMapper mapper = new ObjectMapper().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);
}
}
Add library as dependency to Maven or Gradle. See the actual versions on Maven Central. Java 8 or higher is required to use this library.
- Maven:
<dependencies> <dependency> <groupId>io.github.malczuuu.problem4j</groupId> <artifactId>problem4j-jackson</artifactId> <version>${problem4j-jackson.version}</version> </dependency> </dependencies>
- Gradle (Groovy or Kotlin DSL):
dependencies { implementation("io.github.malczuuu.problem4j:problem4j-jackson:${problem4j-jackson.version}") }
problem4j
- Documentation repository.problem4j-core
- Core library definingProblem
model andProblemException
.problem4j-jackson
- Jackson module for serializing and deserializingProblem
objects.problem4j-spring-web
- Spring Web module extendingResponseEntityExceptionHandler
for handling exceptions and returningProblem
responses.