ttdf
by
yuinijika

Description: The Intuitive Typecho Theme Framework.

View yuinijika/ttdf on GitHub ↗

Summary Information

Updated 17 minutes ago
Added to GitGenius on September 14th, 2025
Created on November 8th, 2024
Open Issues/Pull Requests: 3 (+0)
Number of forks: 5
Total Stargazers: 49 (+0)
Total Subscribers: 1 (+0)
Detailed Description

ttdf (Tiny Textual Data Format) is a lightweight, human-readable data serialization format and corresponding Go library developed by Yuinijika. It aims to be a simpler alternative to formats like JSON or YAML, prioritizing ease of parsing and writing, particularly for configuration files and small data structures. The core philosophy revolves around minimal syntax and a focus on representing basic data types directly as text.

The format itself is remarkably straightforward. ttdf represents data as a series of key-value pairs. Keys are strings, and values can be strings, integers, floats, booleans, lists, or nested dictionaries (maps). Crucially, ttdf avoids complex delimiters like brackets or braces commonly found in JSON. Instead, it uses indentation to denote nesting and a colon (`:`) to separate keys from values. Lists are represented by lines starting with a hyphen (`-`). Boolean values are represented as `true` or `false` (case-insensitive). Strings are generally unquoted unless they contain colons, hyphens, or whitespace that would interfere with parsing. Comments are supported using the `#` symbol. This simplicity makes ttdf files very easy to read and manually edit.

The Go library provides functions for encoding Go data structures into ttdf format and decoding ttdf strings back into Go values. The `ttdf.Encode` function takes a `map[string]interface{}` as input and returns a string representing the ttdf data. The `ttdf.Decode` function performs the reverse operation, parsing a ttdf string and returning a `map[string]interface{}`. Error handling is a key aspect of the library, with functions returning errors to indicate parsing or encoding failures. The library is designed to be performant, leveraging Go's built-in string manipulation capabilities.

A significant feature of ttdf is its extensibility. While the core format supports basic data types, the library allows for custom type handling through the use of `ttdf.Marshaler` and `ttdf.Unmarshaler` interfaces. This enables developers to serialize and deserialize more complex data types, such as dates or custom objects, into ttdf format. The repository includes examples demonstrating how to implement these interfaces for custom types. This flexibility makes ttdf adaptable to a wider range of use cases beyond simple configuration.

The repository also includes a comprehensive suite of unit tests to ensure the correctness and robustness of the library. These tests cover various scenarios, including valid and invalid ttdf strings, different data types, and custom type handling. Furthermore, the repository provides example usage scenarios, demonstrating how to encode and decode data, handle errors, and use custom types. Overall, ttdf offers a compelling alternative to more complex data serialization formats when simplicity and readability are paramount, and the Go library provides a well-tested and extensible solution for working with this format.

ttdf
by
yuinijikayuinijika/ttdf

Repository Details

Fetching additional details & charts...