mojo-toml v0.4.0 - TOML Writer Release π₯
TL;DR: mojo-toml now supports writing TOML files! Build configs programmatically and serialize to TOML format with full round-trip fidelity.
Whatβs New
v0.4.0 adds complete TOML serialization:
from toml import to_toml, TomlValue
fn main() raises:
// Build configuration
var config = Dict[String, TomlValue]()
var app = Dict[String, TomlValue]()
app["name"] = TomlValue("MyApp")
app["version"] = TomlValue("1.0.0")
app["debug"] = TomlValue(True)
config["app"] = TomlValue(app^)
var db = Dict[String, TomlValue]()
db["host"] = TomlValue("localhost")
db["port"] = TomlValue(5432)
config["database"] = TomlValue(db^)
// Write to file
var toml_str = to_toml(config)
with open("config.toml", "w") as f:
f.write(toml_str)
Output:
[app]
name = "MyApp"
version = "1.0.0"
debug = true
[database]
host = "localhost"
port = 5432Features
- β
to_toml()function for Dict β TOML string conversion - β All types: strings, integers, floats, booleans, arrays, tables
- β String escaping, nested structures, table headers
- β Round-trip verified: parse β modify β write β parse preserves semantics
- β 41 new tests (137 total: 96 parser + 41 writer)
Installation
Git submodule:
git submodule add https://github.com/databooth/mojo-toml vendor/mojo-toml
mojo -I vendor/mojo-toml/src your_app.mojoDirect copy:
git clone https://github.com/databooth/mojo-toml
cp -r mojo-toml/src/toml your-project/lib/toml
mojo -I your-project/lib your_app.mojoLinks
- GitHub: https://github.com/databooth/mojo-toml
- Release: https://github.com/DataBooth/mojo-toml/releases/tag/v0.4.0
- Changelog: Full details in CHANGELOG.md
Roadmap
v0.5.0: TOML 1.0 completion - array of tables [[section]], hex/octal/binary integers
v0.6.0: Comparative Python benchmarks, memory profiling
Future: Separate mojo-ini package for INI file support
Zero Python dependencies. Pure Mojo. MIT licensed.
Feedback and contributions welcome! π