Seven runnable programs P01-P07 plus five compile-failure files, JDK 25, no docs/ folder. Output in objectmapper-jsonmapper/output/ is regenerated by scripts/run-all.sh. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b75Ao6imWN5bj7FHVw
3.1 KiB
objectmapper-jsonmapper
Runnable companion for the ankurm.com guide
Jackson ObjectMapper and JsonMapper (Jackson 2 and 3).
Jackson 2 and Jackson 3 sit side by side on one classpath (they live in different packages), so the
same input goes through both mappers in the same JVM and the output can be compared line by line.
There is deliberately no docs/ folder: all explanation lives in the post, and every number in it
comes from a file in output/.
Jackson 3 3.3.0 tools.jackson.core:jackson-databind
Jackson 2 2.23.0 com.fasterxml.jackson.core:jackson-databind (+ jsr310 for the java.time demo)
jackson-annotations 2.23 com.fasterxml.jackson.core (shared by both majors, pulled in by Jackson 3)
JDK Temurin 25.0.5+8
Both 3.3.0 and 2.23.0 appeared on Maven Central on 2026-11-08 (directory listing of repo1.maven.org).
Run
cd objectmapper-jsonmapper
./scripts/run-all.sh # compiles, runs P01-P07, compiles the broken/ files, rewrites output/
Single program: mvn -q compile then
java -cp "target/classes:$(cat target/cp.txt)" com.ankurm.objectmapper.P03ReadWriteCookbook
(run run-all.sh once first so target/cp.txt exists).
Timing lines in P07 are indicative and move between runs; everything else reproduces exactly.
Programs
| File | What it shows | Output |
|---|---|---|
Article.java |
the annotation-free POJO every example uses | - |
P01TwoMappersSideBySide |
same write/read in both majors, and which classes they really are | output |
P02ImmutableMapper |
why Jackson 3 has no setters; rebuild(); Jackson 2 ignoring a late setting |
output |
P03ReadWriteCookbook |
String/byte[]/File/Path/streams, TypeReference, tree, convertValue, readers |
output |
P04ConfigRecipes |
defaults of both majors read from the enums, property order, the config recipe | output |
P05JavaTime |
java.time with and without the module |
output |
P06Exceptions |
checked vs unchecked exceptions, same bad input | output |
P07SharedMapperThreads |
one mapper across 8 threads; shared vs per-call cost | output |
src/broken/ |
five Jackson 2 habits that fail to compile on Jackson 3 | compiler messages |
Gradle
dependencies {
implementation 'tools.jackson.core:jackson-databind:3.3.0'
}