https://github.com/danielkov/toon-rust
Serde-compatible serializer and deserializer for TOON (Token-Oriented Object Notation)
https://github.com/danielkov/toon-rust
Last synced: 8 days ago
JSON representation
Serde-compatible serializer and deserializer for TOON (Token-Oriented Object Notation)
- Host: GitHub
- URL: https://github.com/danielkov/toon-rust
- Owner: danielkov
- Created: 2025-11-13T22:47:06.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2026-03-14T15:46:13.000Z (3 months ago)
- Last Synced: 2026-04-15T02:18:49.015Z (2 months ago)
- Language: Rust
- Size: 156 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# toon
Command-line tool for converting between JSON/YAML and TOON (Token-Oriented Object Notation) formats.
## Installation
```sh
cargo install --git https://github.com/danielkov/toon-rust
```
## Usage
The CLI provides two subcommands: `encode` (JSON/YAML → TOON) and `decode` (TOON → JSON/YAML).
### Encode JSON/YAML to TOON
```sh
toon encode [OPTIONS]
toon e [OPTIONS] # short alias
```
**Options:**
- `--delimiter ` - Array element delimiter (default: comma)
- `--indent ` - Spaces per indentation level (default: 2)
- `--key-folding ` - Key folding mode (default: off)
- `--flatten-depth ` - Maximum depth for inlining nested structures
**Examples:**
```sh
# Convert JSON file to TOON
toon encode data.json
# Convert YAML file to TOON
toon encode data.yaml
# Fetch and convert JSON from URL
toon encode https://api.github.com/users
# Convert inline JSON string
toon e '{"name":"Alice","age":30}'
# Use pipe delimiter for arrays
toon encode --delimiter pipe data.json
```
### Decode TOON to JSON/YAML
```sh
toon decode [OPTIONS]
toon d [OPTIONS] # short alias
```
**Options:**
- `--indent ` - Spaces per indentation level (default: 2)
- `--strict` - Enable strict validation mode
- `--expand-paths ` - Path expansion mode (default: off)
- `-o, --output-type ` - Output format (default: json)
**Examples:**
```sh
# Convert TOON file to JSON
toon decode data.toon
# Convert TOON to YAML
toon decode --output-type yaml data.toon
toon d -o yaml data.toon
# Convert inline TOON string
toon d 'name Alice age 30'
# Enable strict validation
toon decode --strict data.toon
```
## Input Sources
The tool accepts three types of input:
- **File paths** - Reads from local filesystem
- **URLs** - Fetches content via HTTP/HTTPS GET request
- **Raw strings** - Parses string directly from command line argument
## Output
All output is written to stdout. Pipe to a file or other tools as needed:
```sh
toon encode data.json > output.toon
toon decode data.toon | jq .
```