Zoko
A JSON-like format for data storing
Zoko is a human-readable data format that extends JSON with additional features like comments, trailing commas, and multiple string types. It's designed for configuration files, data storage, and any use case where you need the flexibility of JSON with better readability.
Features
- Enhanced Data Types: Support for integers, floats, decimals, dates, times, durations, and binary data
- File Includes: Split configuration into reusable modules using
@include("file.zo") - Environment Variables: Substitute environment variables in backtick strings using
${VAR}syntax - Schema Validation: Built-in schema validation for type safety and structure validation
- Human-Readable Syntax: Clean and intuitive syntax that's easy to read and write
- Comments: Single-line (
//) and multi-line (/* */) comments for better documentation - Trailing Commas: No need to worry about trailing commas - they're fully supported
- Multiple String Types: Double-quoted, single-quoted, and multi-line backtick strings
- JSON & YAML Compatible: Easy conversion between Zoko, JSON, and YAML formats
- Order Preservation: Maintains the original order of objects and maps using IndexMap
- Type Safe: Full Rust API with strong typing and error handling
- CLI Tools: Command-line interface for parsing, validation, and formatting
Installation
You can install Zoko CLI using Zoi:
From Source
# Clone the repository
# Build the project
# The CLI binary will be available at target/release/zoko-cli
Using Cargo
Add to Your Rust Project
Quick Start
Create a Zoko File
Create a file named config.zo:
"My Application",
"1.0.0",
true,
{
"localhost",
5432,
},
["production", "api"],
Parse and Validate
# Validate a Zoko file
# Parse to JSON
# Parse to YAML
# Format a Zoko file
Use in Rust
use ;
Example Zoko File
// Basic configuration
"My Application",
1.0.0,
false,
{
"localhost",
5432,
},
// Enhanced data types
date("2024-06-21"),
duration("30s"),
decimal("19.99"),
// Environment variables (in backtick strings)
`${API_URL:-https://api.example.com}`,
// File includes
@include("common/config.zo"),
@include("database/settings.zo"),
// Tags and metadata
["production", "api"],
"https://example.com",
CLI Commands
# Parse and validate
# Format files
# Check syntax
Advanced Usage
File Includes
Split large configuration files into smaller, reusable modules:
// main.zo
@include("common.zo"),
@include("database.zo"),
"MyApp",
true,
Environment Variables
Use environment variables in configuration:
`${DATABASE_URL}`,
`${API_ENDPOINT:-https://api.example.com}`,
Schema Validation
Define and validate schemas:
use ;
let schema = Schema ;
validate_schema?;