# Boost Serialization Performance Using JSON Arrays

How using arrays instead of objects can improve JSON serialization speed

- **Source:** [Java, SQL and jOOQ.](https://brifing.si/source/27b599b2-cf67-49da-a49f-9552e99765d1)
- **Published:** 2025-08-11
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://blog.jooq.org/consider-using-json-arrays-instead-of-json-objects-for-serialisation/>
- **On Brifing:** https://brifing.si/s/14388ff7-6cf5-49f7-b6f3-15932df48e53

## JSON Serialization and Performance

jOOQ uses JSON arrays to support the MULTISET operator in SQL queries. This approach was developed due to limited support for ARRAY or MULTISET operators in standard SQL. JSON arrays improve performance by enabling positional indexing for data access.

## Arrays Instead of Objects

Using arrays instead of traditional JSON objects significantly boosts data access speed. jOOQ leverages this method by preferring JDBC's positional access methods like ResultSet.getString(int). This also prevents column name conflicts.

## Performance Benefits

Benchmark results show that JSON arrays are 15-25% faster than objects. This difference becomes even more pronounced with larger datasets. Tests on H2 and PostgreSQL confirm this performance gain.

## Readability vs. Performance Trade-off

JSON arrays are less readable compared to objects. However, in systems like jOOQ where users don't directly interact with JSON, this drawback is minimized. The performance gain justifies the readability loss.

## Considerations for API Design

If you're designing an API for external use, readability might outweigh performance. JSON objects provide a clearer model of the data structure. In such cases, performance can take a back seat.

## Compression and Data Transfer

The overhead from repeated keys in JSON objects can be reduced with compression. However, compression and decompression add CPU load. Using JSON arrays avoids this additional overhead.

## Benchmark Results

Tests on H2 and PostgreSQL showed a 15-25% performance increase for small datasets (10 rows) and much higher gains for large datasets (10,000 rows). These results clearly highlight the advantages of JSON arrays.

## Conclusion and Recommendations

JSON arrays are ideal for large-scale, performance-focused applications. However, objects may be more suitable when readability is a priority, such as in API design. Always measure before making a decision.

## Sources covering this story

- https://blog.jooq.org/consider-using-json-arrays-instead-of-json-objects-for-serialisation/ — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
