toonkit2
Type-SafeCompactHuman-ReadableMIT

toonkit2

A parser & serializer for TOON — Typed Object Oriented Notation. Transform JSON to compact TOON format and back with built-in type awareness.

$ npm install toonkit2
Docs → Core parser & Frontend usage
🧭

Core parser & Frontend usage

How the main parser works and using TOON in browsers

The core of `toonkit2` is the parser/serializer pair:

  • toonToJson(input: string) — parse TOON text into typed JavaScript objects.
  • jsonToToon(obj: any) — serialize JS objects into TOON text.

Using the parser in the browser

Two common front-end patterns: fetch the raw TOON response and parse locally, or use `toonFetch` which returns parsed data.

Manual fetch + parse
import { toonToJson } from "toonkit2";

const res = await fetch("/api/devices");
const text = await res.text();
const data = toonToJson(text);
Using toonFetch (direct)
import { toonFetch } from "toonkit2";

const result = await toonFetch("/api/devices");
const data = result.data; // already parsed