Skip to content

Latest commit

 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOON for Julia

Docs SPEC v3.0 License: MIT

Encodes Julia values to TOON (Token-Oriented Object Notation) and decodes TOON back. TOON is a compact, indentation-based encoding of the JSON data model for LLM input.

Installation

using Pkg; Pkg.add("ToonFormat")

Usage

using ToonFormat

users = [(id = 1, name = "Ada", role = "admin"), (id = 2, name = "Bob", role = "user")]
toon = encode((users = users,))
# users[2]{id,name,role}:
#   1,Ada,admin
#   2,Bob,user

decode(toon)
# OrderedDict("users" => [OrderedDict("id" => 1, "name" => "Ada", "role" => "admin"), OrderedDict("id" => 2, "name" => "Bob", "role" => "user")])

Pass EncodeOptions to encode and DecodeOptions to decode through the options keyword, e.g. encode(data; options = EncodeOptions(delimiter = TAB)):

Option Default Description
indent 2 Spaces per indentation level (encode and decode)
delimiter COMMA Array delimiter: COMMA, TAB, or PIPE (encode)
keyFolding "off" "safe" folds chains of single-key objects into dotted keys (encode)
flattenDepth typemax(Int) Maximum segments in a folded key (encode)
strict true Raise the strict-mode errors of spec §14 (decode)
expandPaths "off" "safe" expands dotted keys into nested objects (decode)

Specification

Targets TOON spec v3.0, and the test suite runs the spec's conformance fixtures.

  • Integers decode to Int64 and other numbers to Float64 – tokens outside that domain (e.g. 99999999999999999999, 1e999) decode as strings (§2)
  • Dicts, NamedTuples, and vectors or tuples of Pairs encode as objects – other arrays, tuples, and sets encode as arrays, NaN and ±Inf as null, and anything else (Symbol, Date, missing) as its string form (§3)

Resources

Contributing

See CONTRIBUTING.md for the development setup and pull request guidelines.

License

MIT License © 2025-PRESENT Sébastien Celles

About

🔵 Community-driven Julia implementation of TOON

Topics

Resources

Code of conduct

Contributing

Stars

10 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages