Replacing org.n52 JtsModule for Jackson 3: Introducing io.github.aytronnfr.jackson.jts.JtsModule

Published: (February 20, 2026 at 10:59 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

TL;DR

jts-jackson3-module provides GeoJSON serialization/deserialization for JTS on Jackson 3.
It is designed for Spring Boot 4.x projects using tools.jackson.* and includes round‑trip and compatibility tests to reduce migration risk.

Why this module exists

Spring Boot 4 moves to Jackson 3, so many older JSON modules built around Jackson 2 package names no longer fit cleanly.
For JTS geometries this can block migration or force ugly temporary workarounds.

This module is a drop‑in migration path for teams that need:

  • clean support for org.locationtech.jts geometries,
  • GeoJSON read/write behavior,
  • modern build/publish workflow (GitHub Packages + Maven Central).

Compatibility targets

jts-jackson3-module is built for:

  • Spring Boot 4.x
  • Jackson 3 (tools.jackson.*)
  • JTS (org.locationtech.jts)

Dependency

dependencies {
    implementation("io.github.aytronnfr:jts-jackson3-module:0.1.0")
}

Basic usage

import io.github.aytronnfr.jackson.jts.JtsModule;
import tools.jackson.databind.json.JsonMapper;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.PrecisionModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JsonConfig {

    @Bean
    public GeometryFactory geometryFactory() {
        return new GeometryFactory(new PrecisionModel(), 4326);
    }

    public static void configJsonMapper(GeometryFactory geometryFactory,
                                        JsonMapper.Builder builder) {
        // 1) Modules
        builder.addModule(new JtsModule(geometryFactory));
        // ...
    }
}

That’s enough to start serializing/deserializing JTS geometries in a Jackson 3 stack.

Advanced usage: include bbox for selected geometry types

import io.github.aytronnfr.jackson.jts.GeometryType;
import io.github.aytronnfr.jackson.jts.IncludeBoundingBox;
import io.github.aytronnfr.jackson.jts.JtsModule;

var module = new JtsModule(
        IncludeBoundingBox.forTypes(GeometryType.POINT), 8);

This lets you control output precision and bounding‑box behavior for targeted geometry classes.

Migration notes from org.n52... module

When migrating, follow this order:

  1. Replace the dependency with io.github.aytronnfr:jts-jackson3-module.
  2. Register new JtsModule() in your Jackson 3 JsonMapper configuration.
  3. Run contract tests against existing API payload fixtures.
  4. Validate edge cases: precision, bbox output, null geometry handling.
  5. Roll out with a canary if geospatial payloads are customer‑facing.

Testing strategy used in the project

The repository includes:

  • Round‑trip tests for Jackson 3 behavior,
  • Compatibility tests against the legacy org.n52.jackson:jackson-datatype-jts:2.0.0,
  • Shared fixtures for deterministic comparisons.

These tests guard against subtle regressions (ordering, precision, bbox shape) that can break downstream consumers silently.

CI/CD and publishing

GitHub Actions are configured for:

  • CI on push/PR,
  • Publishing on version tags,
  • Manual release flow.

Publishing targets:

  • GitHub Packages
  • Maven Central

Practical impact for Boot 4 teams

In real migrations, this module removes a key blocker: staying with old module assumptions while the rest of the app has already moved to Jackson 3.
You keep your geospatial payload capability without freezing your platform upgrade.

What’s next

Roadmap items:

  • Expand compatibility fixtures,
  • Benchmark serialization overhead on larger geometry sets,
  • Document migration recipes for common Spring Boot setups.

If you’re migrating a GIS‑heavy API to Boot 4, feedback and issue reports are very welcome.

Repository:

0 views
Back to Blog

Related posts

Read more »