JSON: Measure Twice, Parse Once


JSON parsing/writing is the part of a data pipeline one usually does not think about, until the profiler says it eats half of CPU. Jackson is the default answer, and for good reason. But how much do you actually gain by leaving it, and what do you pay for it?

TLDR: Jsoniter with Javassist is about 3x faster than Jackson, DSL-JSON about 2x. Jsoniter has not had a release since 2018, DSL-JSON is effectively maintained by one person. Unless parsing is your proven bottleneck, stay with Jackson. Protobuf JsonFormat is not a JSON parser you want on a hot path at all (to be honest, Google admits it in docs).

The Setup

The dataset is the Open Library authors dump: 14.6 million JSON lines, 4.6 GB. The benchmark reads the first 1,000,000 lines into memory, so one JMH operation means 1,000,000 deserializations into the same Author POJO. Disk and decompression are out of the picture, only parsing and object creation are measured.

The data is deliberately real-world messy. Most fields are optional, bio is sometimes a string and sometimes an object {"type": ..., "value": ...}, there are nested objects, lists of strings, and timestamps.

  • JDK 25, JMH, 1 fork, 1 warmup and 5 measurement iterations
  • Jackson 2.22 and 3.2, Jsoniter 0.9.23, DSL-JSON 2.0.2, Protobuf 4.32, Avro 1.10.2
  • Result is average ms per 1,000,000 lines, lower is better

Results

Benchmark ms
Jsoniter, Javassist, into Avro SpecificRecord 636
Jsoniter, Javassist 638
DSL-JSON, reused reader 927
DSL-JSON 968
Jsoniter, dynamic mode 1045
DSL-JSON, hand-written parser 1259
Jsoniter into Avro 1311
DSL-JSON into Avro, reused reader 1373
DSL-JSON into Avro 1386
Jackson, streaming API 1625
Jackson, ObjectMapper 1873
Jackson 3, ObjectMapper 1909
Jackson into Avro 1855
Protobuf JsonFormat 5412

Serialization is the same story:

Benchmark ms
Jsoniter, Javassist 588
DSL-JSON, reused writer 730
DSL-JSON 875
Jackson ObjectMapper 1335
Jackson 3 ObjectMapper 1394
Jsoniter, dynamic mode 1795
Protobuf JsonFormat 4639

Error margins are 5-30%, so treat anything below that as noise. Jackson 2 vs Jackson 3 is a tie. Reusing the DSL-JSON reader is within noise too.

What the numbers say:

  • Jsoniter with Javassist codegen is the fastest, roughly 3x Jackson on parsing and 2.3x on writing.
  • DSL-JSON is about 2x Jackson, without any runtime bytecode generation, the converters are generated at compile time.
  • Jsoniter in default dynamic mode is only 1.8x on parsing and, surprisingly, slower than Jackson on writing. The speed comes from the Javassist mode, not from the library itself.
  • Hand-written streaming parsers help only Jackson (about 13%). For DSL-JSON the generated converter beat my hand-written one.
  • Protobuf JsonFormat is 3-9x slower than everything else. It is built for interoperability and debugging, not throughput. If you have Protobuf messages, use the binary format and render JSON only at the edges.

Avro: Is Reading JSON Into Avro Records Any Different?

A common pipeline step is JSON in, Avro SpecificRecord out. I tried filling the generated Avro classes directly with each library. The ranking stays the same: Jsoniter 636 ms, DSL-JSON 1386 ms, Jackson 1855 ms.

There is a catch, and it is not a performance one. The Avro schema I wrote did not fit the data. Encoding the first 100,000 records with toByteBuffer() failed for 135 of them, because links entries contain nested objects the schema did not expect. JSON is schemaless, and the first few thousand records will happily lie to you about what the rest looks like. The parsing library cannot save you here, only a validation step can.

How Hard Is It to Implement?

Jackson is the baseline. Annotate the POJO with @JsonProperty and @JsonIgnoreProperties(ignoreUnknown = true), create an ObjectMapper, done. Optional fields, nulls, Instant through the JSR-310 module, polymorphic bio through @JsonTypeInfo or a custom deserializer, all documented, all answered on StackOverflow. Writing a streaming parser by hand is possible, but you have to map every field yourself, and for 13% I would not.

DSL-JSON is a bit more work:

  • annotation processor in the build, with -Adsljson.jackson=true to understand Jackson annotations and -Adsljson.unknown=ALLOW to ignore unknown properties
  • @CompiledJson on every class including nested ones
  • Settings.basicSetup() at runtime, otherwise the Object-typed bio field is not resolved
  • converters are plain generated Java source, so when something breaks, you can read and debug it

Once set up, it behaves. The learning curve is mostly in finding which of the flags you need, the documentation is thin and you will read the source.

Jsoniter is the hardest, and the fast mode is the trap:

  • the default dynamic mode is easy, but not that fast
  • the fast mode needs Javassist, which on JDK 17+ requires --add-opens=java.base/java.lang=ALL-UNNAMED on every JVM that runs it, including your Flink task managers or whatever runs the code
  • the old Javassist 3.21 is pinned by the library
  • types like Instant or CharSequence need custom decoders registered
  • mode and decoder registrations are process-wide static state, so two components in one JVM wanting different settings will fight over them; I had to keep a separate fork for every benchmark
  • a static codegen mode exists too (STATIC_MODE), generating sources in a Maven profile, but it needs its own configuration class and working directory tricks

It took by far the most time to get right, and I would not be able to tell you with confidence it keeps working on JDK

27.

Maintenance

Speed is a number you measure once. Maintenance is a cost you pay every sprint.

  Jackson DSL-JSON Jsoniter
Last release 2.22.x / 3.2.x 2.0.2 0.9.23 (2018-07-03)
Last commit active 2026-10-24 2022-01-23
Maintainers large community effectively one effectively none

(checked 2026-10-29)

Jackson is a safe bet, with security fixes arriving fast, and every framework you use already has it on the classpath. DSL-JSON is alive, but if the maintainer loses interest, you are on your own. Jsoniter is abandoned. The last release is eight years old, it works today only because of the --add-opens flag, and any CVE found in it stays there. Putting it into a long-lived production system is a decision to own the library yourself.

Conclusion

  • Parsing 1,000,000 records takes 1.9 s with Jackson and 0.64 s with Jsoniter. That is about 1.3 microseconds per record of difference. If your pipeline does network I/O or any real work per record, you will not see it.
  • If parsing is a measured bottleneck, DSL-JSON gives 2x with a reasonable maintenance story.
  • Jsoniter is great for a benchmark and a risk for a product. Use it only if you are ready to fork it.
  • Do not use Protobuf JsonFormat for bulk JSON.
  • Whatever you pick, validate against your schema early. The Avro mismatch cost me more time than any parser choice.

Start with Jackson, measure, and only then pay for the speed.