ToonFormat.jl
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 – the Format Overview covers its syntax.
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")])A Dict iterates in hash order, so encode a NamedTuple or an OrderedDict from OrderedCollections.jl when the field order matters. decode throws an ErrorException naming the line on invalid input, e.g. Line 3: Expected 3 tabular rows, but got 2. Options covers delimiters and strict mode.
Specification
The README names the targeted spec version and how Julia values map to the JSON data model.