Go implementation of the TOON data format.
goon is a high-performance, strictly compliant Go library and CLI for parsing and generating TOON (The Object-Oriented Notation) data.
- 🚀 Fast & Efficient: Built with performance in mind using a custom scanner and recursive descent parser.
- 🔄 Marshal/Unmarshal: Direct conversion between Go structs and TOON format with struct tag support (like
encoding/json). - 🔒 Strict Mode: Optional strict validation to ensure your TOON files are perfectly formatted (no tabs, correct indentation).
- 🛠️ CLI Tools: Includes
goon encodeandgoon decodefor easy integration into existing workflows. - 📦 Zero Dependencies: The core library has no external dependencies.
Linux & macOS
curl -fsSL https://raw.githubusercontent.com/tnfssc/goon/develop/scripts/install.sh | shWindows (PowerShell)
irm https://raw.githubusercontent.com/tnfssc/goon/develop/scripts/install.ps1 | iexTo use Goon in your Go project:
go get github.com/tnfssc/goonTo install the command-line tool:
go install github.com/tnfssc/goon/cmd/goon@latestpackage main
import (
"fmt"
"log"
"github.com/tnfssc/goon/pkg/toon"
)
type Config struct {
Name string `toon:"name"`
Version string `toon:"version"`
Features []string `toon:"features"`
}
func main() {
// Marshal Go struct to TOON (like json.Marshal)
config := Config{
Name: "MyApp",
Version: "1.0.0",
Features: []string{"fast", "reliable", "simple"},
}
toonData, err := toon.Marshal(config, toon.EncodeOptions{IndentSize: 2})
if err != nil {
log.Fatal(err)
}
fmt.Println(string(toonData))
// Unmarshal TOON to Go struct (like json.Unmarshal)
var decoded Config
err = toon.Unmarshal(toonData, &decoded, toon.DecodeOptions{IndentSize: 2})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Decoded: %+v\n", decoded)
}Convert JSON to TOON:
goon encode input.json > output.toonConvert TOON back to JSON:
goon decode input.toon > output.jsonPipe from stdin:
# JSON to TOON
cat data.json | goon encode > data.toon
# TOON to JSON
cat config.toon | goon decode > config.json
# Chain with other tools
curl https://api.example.com/data.json | goon encode > api-data.toonGoon supports the full TOON specification, including:
- Key-Value Pairs: Simple
key: valuesyntax. - Nested Objects: Indentation-based hierarchy.
- Arrays:
- List format:
key: [length|]followed by- itemlines. - Coming Soon: Inline arrays and tabular arrays.
- List format:
- Primitives: Strings, numbers, booleans, and null.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.