DEV Community

John DeRegnaucourt
John DeRegnaucourt

Posted on

Java Finally Gets TOON Support: json-io 4.85.0

Java Finally Gets TOON Support: json-io 4.85.0

I've seen the excellent TOON articles here on Dev.to lately (this one, this one), and noticed something: most implementations were for

TypeScript, Python, Go... but Java was underserved.

As the author of json-io, I decided to fix that.

What's TOON?

Quick refresher: TOON (Token-Oriented Object Notation) is designed for LLM efficiency. It looks like this:

  name: John Smith                                                                                                                                                                                                                                                                                                       
  age: 30                                                                                                                                                                                                                                                                                                                
  skills[3]: Java,Spring,Kubernetes                                                                                                                                                                                                                                                                                      
  address:                                                                                                                                                                                                                                                                                                               
    city: Austin                                                                                                                                                                                                                                                                                                         
    zip: 78701                                                                                                                                                                                                                                                                                                           
Enter fullscreen mode Exit fullscreen mode

vs JSON:

{
  "name":"John Smith",
  "age":30,"skills":["Java","Spring","Kubernetes"],
  "address":{"city":"Austin","zip":"78701"}
}                                                                                                                                                                                                       
Enter fullscreen mode Exit fullscreen mode

Result: 40-50% fewer tokens, which directly translates to cost savings and larger context windows.

Java Usage

  // Any Java object → TOON                                                                                                                                                                                                                                                                                              
  String toon = JsonIo.toToon(employee, writeOptions);                                                                                                                                                                                                                                                                   

  // TOON → Java object                                                                                                                                                                                                                                                                                                  
  Employee emp = JsonIo.fromToon(toon, readOptions).asClass(Employee.class);                                                                                                                                                                                                                                             

  // Works with generics too                                                                                                                                                                                                                                                                                             
  List<Employee> team = JsonIo.fromToon(toon, readOptions)                                                                                                                                                                                                                                                               
      .asType(new TypeHolder<List<Employee>>(){});                                                                                                                                                                                                                                                                       
Enter fullscreen mode Exit fullscreen mode

Why This Matters for Java AI Development

If you're using:

json-io gives you a drop-in solution today. Same library that handles your JSON can now handle TOON.

Full Feature Set

  • Read AND write support (not just one direction)
  • Complex object graphs with nested structures
  • Collections, Maps, arrays, JDK object types (ZonedDateTime, etc.)
  • Generic type support via TypeHolder
  • String or Stream-based I/O
  • All the robustness json-io is known for

Repo: https://github.com/jdereg/json-io

Happy to answer questions in the comments!


Top comments (0)