unit-test-json-serialization

Installation
Summary

Unit testing JSON serialization and deserialization with Spring's @JsonTest and Jackson.

  • Covers serialization/deserialization of POJOs, custom serializers/deserializers, field name mappings with @JsonProperty, and null handling using JacksonTester for type-safe assertions
  • Includes patterns for testing nested objects, lists, date/time formatting, and polymorphic types with @JsonTypeInfo
  • Provides Maven and Gradle setup, best practices for avoiding circular references and null inclusion issues, and troubleshooting guidance for common Jackson configuration problems
  • Uses @JsonTest annotation for lightweight JSON-focused test context without full Spring application startup
SKILL.md

Unit Testing JSON Serialization with @JsonTest

Overview

Provides patterns for unit testing JSON serialization and deserialization using Spring's @JsonTest and Jackson. Covers POJO mapping, custom serializers, field name mappings, nested objects, date/time formatting, and polymorphic types.

When to Use

  • Testing JSON serialization/deserialization of DTOs
  • Verifying custom Jackson serializers/deserializers
  • Validating @JsonProperty, @JsonIgnore, and field name mappings
  • Testing date/time format handling (LocalDateTime, Date)
  • Testing null handling and missing fields
  • Testing polymorphic type deserialization

Instructions

  1. Annotate test class with @JsonTest → Enables JacksonTester auto-configuration
  2. Autowire JacksonTester for target type → Provides type-safe JSON assertions
Related skills

More from giuseppe-trisciuoglio/developer-kit

Installs
887
GitHub Stars
246
First Seen
Feb 3, 2026