Backend Development 11 min read

Performance Benchmark of Common Java JSON Libraries Using JMH

This article benchmarks the serialization and deserialization performance of four popular Java JSON libraries—Gson, Fastjson, Jackson, and Json‑lib—using JMH, analyzes the results across different operation counts, and provides guidance on selecting the most suitable library for high‑performance applications.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Performance Benchmark of Common Java JSON Libraries Using JMH

In this article the author evaluates the performance of four popular Java JSON libraries—Gson, Fastjson, Jackson, and Json‑lib—by writing JMH benchmarks for both serialization and deserialization of a complex Person model.

The article first introduces each library, their background, Maven dependencies, and provides simple utility classes ( FastJsonUtil , GsonUtil , JacksonUtil , JsonLibUtil ) for converting between Java objects and JSON strings.

A representative Person class with nested objects, collections, and maps is defined to simulate real‑world data. Two JMH benchmark classes ( JsonSerializeBenchmark and JsonDeserializeBenchmark ) are presented, each parameterized with different operation counts (1 000, 10 000, 100 000) and measuring single‑shot execution time.

Results, exported to ECharts charts, show that for small counts Gson is fastest, while at larger counts Jackson and Fastjson outperform Gson; Json‑lib is consistently the slowest. Deserialization performance is similar among Gson, Jackson and Fastjson, with Json‑lib again lagging.

The article concludes with a brief commentary on choosing a JSON library based on performance needs and invites readers to join the author’s community for further discussion.

JavaPerformance BenchmarkJSONfastjsonGsonJacksonJMH
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.