A Java serialization library that converts objects to/from JSON, JSON5, and TOON formats, handling complex graphs and reducing LLM token usage by 40-50%.
json-io is a Java serialization library that converts Java objects to and from JSON, JSON5, and TOON formats. It solves the problem of serializing complex object graphs with cyclic references and polymorphic types, which standard libraries like Jackson and Gson cannot handle. Additionally, its TOON format reduces token usage by 40-50%, making it ideal for cost-sensitive LLM applications.
Java developers building applications that require robust object serialization, especially those working with complex data models, Spring Boot/Spring AI integrations, or LLM-powered features where token efficiency is critical.
Developers choose json-io because it handles complex serialization scenarios out-of-the-box—like cyclic graphs and polymorphism—without extensive configuration. Its TOON format offers significant token savings for LLM interactions, and it integrates seamlessly with Spring ecosystems while maintaining compatibility with existing Jackson annotations.
Convert Java to JSON/TOON and back. Supports complex object graphs, cyclic references, and TOON format for 40-50% LLM token savings
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Serializes to TOON format, reducing token count by 40-50% for LLM applications, as shown in the comparison where team data uses ~45% fewer tokens by eliminating braces and commas.
Supports cyclic references and object relationships with built-in cycle detection using @id/@ref markers, a feature missing in Jackson and Gson.
Automatically serializes 60+ built-in Java types without annotations, including primitives, collections, and date/time classes, as listed in the Supported Types section.
Provides starters for Spring Boot and Spring AI, enabling seamless TOON serialization in REST APIs via Accept headers and LLM tool calls with ToonBeanOutputConverter.
Reflectively honors Jackson annotations without a compile-time dependency, allowing easy migration from Jackson-based codebases with annotations like @JsonProperty and @JsonIgnore.
Prioritizes correctness over speed; the README admits Jackson and Gson are faster for simple DTOs, and enabling cycle support can slow writes by 35-40% for acyclic data.
Requires the java-util library, adding ~700K to the project size, which might be unnecessary for projects that only need basic serialization without complex features.
Only supports JSON, JSON5, and TOON; lacks native support for other common formats like YAML, XML, or Protocol Buffers, limiting versatility in polyglot environments.
While zero-config for common cases, advanced features like custom serializers or unsafe deserialization require detailed setup via ReadOptionsBuilder and WriteOptionsBuilder, adding complexity.
JSON-io is an open-source alternative to the following products:
Jackson is a suite of data-processing libraries for Java, primarily known for its JSON parsing and generation capabilities, supporting data binding and streaming APIs.
Gson is a Java library developed by Google that converts Java objects into their JSON representation and vice versa, providing a simple API for JSON serialization and deserialization.