A Go implementation of the DAN (Data Advanced Notation) parser and encoder with a command-line interface.
- Parse DAN format - Convert DAN text to structured data
- Encode to DAN - Convert structured data (JSON or DAN) to DAN format
- Pretty-print - Format DAN files for better readability
- JSON support - Convert between DAN and JSON formats
go build -o dan cmd/dan/main.goOr install directly:
go install ./cmd/danConvert DAN format to JSON or pretty-printed DAN:
# Decode from file
dan decode file.dan
# Decode from stdin
cat file.dan | dan decode
# Output as JSON
dan decode -json file.danConvert JSON or DAN to DAN format:
# Encode JSON file to DAN
dan encode -json file.json
# Encode DAN file (pretty-print)
dan encode file.danFormat DAN files:
dan pretty file.danDAN (Data Advanced Notation) is a human-readable data format that supports:
- Key-value pairs:
key: value - Nested objects:
key { ... } - Tables:
key: table(col1, col2) [ ... ] - Arrays:
key: [value1, value2] - Comments:
# commentor// comment - Data types: strings, numbers, booleans, arrays
name: "John Doe"
age: 30
active: true
tags: ["developer", "go"]
address {
street: "123 Main St"
city: "New York"
zip: 10001
}
users: table(name, age, email) [
"Alice", 25, "alice@example.com"
"Bob", 30, "bob@example.com"
]
You can also use the DAN library in your own Go programs:
package main
import (
"fmt"
"github.com/marcuwynu23/godan/lib"
)
func main() {
// Decode DAN text
data, err := lib.Decode(`name: "test"`)
if err != nil {
panic(err)
}
fmt.Println(data)
// Encode to DAN
obj := map[string]interface{}{
"name": "test",
"age": 30,
}
output := lib.Encode(obj)
fmt.Println(output)
}Parser tests run in the godan module (github.com/marcuwynu23/godan), checked out at ../dango in this monorepo:
go -C ../dango test ./...Verbose and benchmarks:
go -C ../dango test ./... -v
go -C ../dango test ./... -bench=. -benchmemFrom this directory you can also use make test, make test-verbose, and make bench.
Use go -C ../dango test ./... or make test to exercise the library the CLI depends on (github.com/marcuwynu23/godan/lib).
dan-cli/
├── cmd/dan/main.go # CLI entrypoint
├── examples/ # Sample .dan files
├── go.mod # depends on github.com/marcuwynu23/godan/lib
└── README.md
- Contributing · Code of Conduct · Security
- Funding / PayPal (also via
.github/FUNDING.ymlSponsor button)
MIT