mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34:10 +08:00
feat!: publish to @toon-format/toon and @toon-format/cli
This commit is contained in:
34
README.md
34
README.md
@@ -3,9 +3,9 @@
|
||||
# Token-Oriented Object Notation (TOON)
|
||||
|
||||
[](https://github.com/johannschopplich/toon/actions)
|
||||
[](https://www.npmjs.com/package/@byjohann/toon)
|
||||
[](https://www.npmjs.com/package/@toon-format/toon)
|
||||
[](./SPEC.md)
|
||||
[](https://www.npmjs.com/package/@byjohann/toon)
|
||||
[](https://www.npmjs.com/package/@toon-format/toon)
|
||||
[](./LICENSE)
|
||||
|
||||
**Token-Oriented Object Notation** is a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage. It's intended for LLM input, not output.
|
||||
@@ -439,19 +439,19 @@ Four datasets designed to test different structural patterns (all contain arrays
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install @byjohann/toon
|
||||
npm install @toon-format/toon
|
||||
|
||||
# pnpm
|
||||
pnpm add @byjohann/toon
|
||||
pnpm add @toon-format/toon
|
||||
|
||||
# yarn
|
||||
yarn add @byjohann/toon
|
||||
yarn add @toon-format/toon
|
||||
```
|
||||
|
||||
**Example usage:**
|
||||
|
||||
```ts
|
||||
import { encode } from '@byjohann/toon'
|
||||
import { encode } from '@toon-format/toon'
|
||||
|
||||
const data = {
|
||||
users: [
|
||||
@@ -473,20 +473,20 @@ Command-line tool for converting between JSON and TOON formats.
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
npx @byjohann/toon <input> [options]
|
||||
npx @toon-format/cli <input> [options]
|
||||
```
|
||||
|
||||
**Auto-detection:** The CLI automatically detects the operation based on file extension (`.json` → encode, `.toon` → decode).
|
||||
|
||||
```bash
|
||||
# Encode JSON to TOON (auto-detected)
|
||||
toon input.json -o output.toon
|
||||
npx @toon-format/cli input.json -o output.toon
|
||||
|
||||
# Decode TOON to JSON (auto-detected)
|
||||
toon data.toon -o output.json
|
||||
npx @toon-format/cli data.toon -o output.json
|
||||
|
||||
# Output to stdout
|
||||
toon input.json
|
||||
npx @toon-format/cli input.json
|
||||
```
|
||||
|
||||
### Options
|
||||
@@ -506,16 +506,16 @@ toon input.json
|
||||
|
||||
```bash
|
||||
# Show token savings when encoding
|
||||
toon data.json --stats -o output.toon
|
||||
npx @toon-format/cli data.json --stats -o output.toon
|
||||
|
||||
# Tab-separated output (often more token-efficient)
|
||||
toon data.json --delimiter "\t" -o output.toon
|
||||
npx @toon-format/cli data.json --delimiter "\t" -o output.toon
|
||||
|
||||
# Pipe-separated with length markers
|
||||
toon data.json --delimiter "|" --length-marker -o output.toon
|
||||
npx @toon-format/cli data.json --delimiter "|" --length-marker -o output.toon
|
||||
|
||||
# Lenient decoding (skip validation)
|
||||
toon data.toon --no-strict -o output.json
|
||||
npx @toon-format/cli data.toon --no-strict -o output.json
|
||||
```
|
||||
|
||||
## Format Overview
|
||||
@@ -741,7 +741,7 @@ A TOON-formatted string with no trailing newline or spaces.
|
||||
**Example:**
|
||||
|
||||
```ts
|
||||
import { encode } from '@byjohann/toon'
|
||||
import { encode } from '@toon-format/toon'
|
||||
|
||||
const items = [
|
||||
{ sku: 'A1', qty: 2, price: 9.99 },
|
||||
@@ -862,7 +862,7 @@ A JavaScript value (object, array, or primitive) representing the parsed TOON da
|
||||
**Example:**
|
||||
|
||||
```ts
|
||||
import { decode } from '@byjohann/toon'
|
||||
import { decode } from '@toon-format/toon'
|
||||
|
||||
const toon = `
|
||||
items[2]{sku,qty,price}:
|
||||
@@ -980,7 +980,7 @@ Task: Return only users with role "user" as TOON. Use the same header. Set [N] t
|
||||
## Other Implementations
|
||||
|
||||
> [!NOTE]
|
||||
> When implementing TOON in other languages, please follow the [SPEC.md](./SPEC.md) (currently v1.3) to ensure compatibility across implementations. The [TypeScript test suite](./test) provides comprehensive examples of encoding and decoding behavior that can serve as a reference implementation.
|
||||
> When implementing TOON in other languages, please follow the [SPEC.md](./SPEC.md) (currently v1.3) to ensure compatibility across implementations. The [TypeScript test suite](./packages/toon/test) provides comprehensive examples of encoding and decoding behavior that can serve as a reference implementation.
|
||||
|
||||
- **.NET:** [ToonSharp](https://github.com/0xZunia/ToonSharp)
|
||||
- **Crystal:** [toon-crystal](https://github.com/mamantoha/toon-crystal)
|
||||
|
||||
Reference in New Issue
Block a user