T-JSON Batch API
This page groups the non-streaming APIs that produce or consume T-JSON text. Use the language tabs to switch between Python, JavaScript, and Rust.
Batch parse APIs still auto-detect T-TOON, T-JSON, and typed_unit input. The functions listed here are grouped by their T-JSON use case, not by exclusive parser support.
- Python
- JavaScript / TypeScript
- Rust
Package: ttoon
Read T-JSON Batch Text
loads(text, mode=None) -> object
- Parses
T-JSON,T-TOON, ortyped_unittext to Python native objects modeonly affects the T-TOON parse path
read_arrow(text) -> pyarrow.Table
- Parses batch text to
pyarrow.Table - Auto-detects format
- Input must be a list of uniform objects with scalar fields
Write T-JSON Batch Text
to_tjson(obj, binary_format=None) -> str
- Serializes Python objects to T-JSON text
- Does not accept Arrow / Polars input
stringify_arrow_tjson(obj, binary_format=None) -> str
- Serializes
pyarrow.Table,pyarrow.RecordBatch, orpolars.DataFrameto T-JSON list-of-objects
Transcode into T-JSON
ttoon_to_tjson(text, *, mode="compat", binary_format=None) -> str
- Converts T-TOON text directly to T-JSON through Rust IR only
mode:"compat"(default) or"strict"
T-JSON Batch Options
| Parameter | APIs | Values | Default |
|---|---|---|---|
binary_format | to_tjson, stringify_arrow_tjson, ttoon_to_tjson | "hex", "b64" | "hex" |
mode | loads, ttoon_to_tjson | "compat", "strict" | "compat" |
Related Utilities
detect_format(text) -> stris documented on Format DetectionTranscodeErrordetails remain the same regardless of which batch format you target
Package: @ttoon/shared
Read T-JSON Batch Text
parse<T>(text, options?): T
- Parses
T-JSON,T-TOON, ortyped_unittext to JS values ParseOptions:
| Property | Type | Default | Description |
|---|---|---|---|
mode | 'compat' | 'strict' | 'compat' | Parse mode for the T-TOON / typed-unit path |
codecs | CodecRegistry | — | Per-call codec overrides |
readArrow(text): Promise<ArrowTable>
- Parses batch text to Arrow Table
- Auto-detects format
- Requires
apache-arrow
Write T-JSON Batch Text
toTjson(value, options?): string
- Serializes JS values to T-JSON text
TjsonSerializeOptions:
| Property | Type | Default | Description |
|---|---|---|---|
binaryFormat | 'hex' | 'b64' | 'hex' | Binary encoding |
stringifyArrowTjson(table, options?): Promise<string>
- Serializes Arrow Table to T-JSON list-of-objects
- Requires
apache-arrow
Transcode into T-JSON
ttoonToTjson(text, options?): string
- Converts T-TOON text directly to T-JSON text
TtoonToTjsonOptionsextendsTjsonSerializeOptionsand addsmode?: ParseMode
Note: for JS direct transcode, TranscodeError.phase is currently not reliable. Prefer sourceKind and the underlying source.message.
Related Utilities
detectFormat(text)is documented on Format Detection- JS type markers such as
toon.uuid()andtoon.decimal()apply when you serialize JS values into T-JSON
Crate: ttoon-core
Read T-JSON Batch Text
fn from_ttoon(text: &str) -> Result<ir::Node>
fn from_ttoon_with_mode(text: &str, mode: ParseMode) -> Result<ir::Node>
fn read_arrow(text: &str) -> Result<ir::ArrowTable>
- Despite the historical function name, these APIs auto-detect T-JSON input too
read_arrow()supports arrowable batch text regardless of whether the input is T-TOON or T-JSON
Write T-JSON Batch Text
fn to_tjson(node: &ir::Node, opts: Option<&TjsonOptions>) -> Result<String>
fn arrow_to_tjson(table: &ir::ArrowTable, opts: Option<&TjsonOptions>) -> Result<String>
Transcode into T-JSON
fn ttoon_to_tjson(text: &str, mode: ParseMode, opts: Option<&TjsonOptions>) -> Result<String>
Configuration Types
TjsonOptions
pub struct TjsonOptions {
pub binary_format: BinaryFormat,
}
ParseMode
pub enum ParseMode {
Strict,
Compat,
}
BinaryFormat
pub enum BinaryFormat { Hex, B64 }
Related Utilities
detect_format(input: &str)is documented on Format Detection- Shared schema and streaming types are documented on Stream API
Related Pages
- T-TOON Batch API — Batch APIs centered on T-TOON text
- Stream API — Row-by-row readers and writers
- Typed Value Reference — Value-level semantics shared by both batch syntaxes