Skip to main content

Quick Start

This guide covers the shortest path to productive use:

  1. Serialize and deserialize objects
  2. Generate T-JSON output
  3. Work with tabular data and Arrow
  4. Transcode between formats

1. Object Round Trip

import ttoon

data = {"name": "Alice", "age": 30, "id": "A-001"}

text = ttoon.dumps(data)
print(text)
# name: "Alice"
# age: 30
# id: "A-001"

restored = ttoon.loads(text)

2. Generating T-JSON

T-JSON uses JSON-like {} / [] brackets while keeping typed syntax at the value layer.

import datetime as dt
import ttoon

text = ttoon.to_tjson({
"created_at": dt.datetime(2026, 3, 8, 10, 30, 0),
"score": 12.5,
})
print(text)
# {"created_at": 2026-03-08T10:30:00, "score": 12.5}

3. Tabular Data & Arrow

When data is a list of uniform objects, T-TOON automatically outputs tabular format:

[2]{name,score}:
"Alice", 95
"Bob", 87
import polars as pl
import ttoon

df = pl.DataFrame({"name": ["Alice", "Bob"], "score": [95, 87]})

text = ttoon.dumps(df)
table = ttoon.read_arrow(text) # returns pyarrow.Table
  • dumps(df) converts to Arrow internally, then serializes via the Rust core — no list[dict] intermediate
  • read_arrow() returns a pyarrow.Table directly

4. Direct Transcode

Convert between T-JSON and T-TOON without materializing language-native objects — the text passes through Rust IR only.

import ttoon

ttoon_text = ttoon.tjson_to_ttoon('{"name": "Alice", "scores": [95, 87]}')
tjson_text = ttoon.ttoon_to_tjson('name: "Alice"\nage: 30')

Next Steps