Skip to content

malczuuu/problem4j-jackson

Repository files navigation

Problem4J Jackson

JitPack Build Status

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.

Features

  • ✅ 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

Example

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);

Usage

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>")
}

About

Jackson module for library implementing RFC7807

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages