| Crates.io | zenbase-llml |
| lib.rs | zenbase-llml |
| version | 0.2.0 |
| created_at | 2025-06-29 09:37:23.11741+00 |
| updated_at | 2025-06-29 09:37:23.11741+00 |
| description | Lightweight Language Markup Language - converts data structures to XML-like markup |
| homepage | |
| repository | https://github.com/zenbase-ai/llml |
| max_upload_size | |
| id | 1730592 |
| size | 45,809 |
Rust implementation of the Lightweight Markup Language (LLML) - a library that converts JSON data structures into XML-like markup with intelligent formatting.
{"key": "value"} → <key>value</key>Add this to your Cargo.toml:
[dependencies]
llml = "0.1.0"
use llml::llml;
use serde_json::json;
fn main() {
// Simple key-value pairs
let data = json!({"instructions": "Follow these steps"});
println!("{}", llml(&data, None));
// Output: <instructions>Follow these steps</instructions>
// Arrays become numbered lists
let data = json!({"rules": ["first", "second", "third"]});
println!("{}", llml(&data, None));
// Output:
// <rules>
// <rules-1>first</rules-1>
// <rules-2>second</rules-2>
// <rules-3>third</rules-3>
// </rules>
}
use llml::{llml, Options};
use serde_json::json;
let data = json!({"message": "Hello World"});
let options = Some(Options {
indent: " ".to_string(),
prefix: "app".to_string(),
strict: false,
});
let result = llml(&data, options);
// Output: <app-message>Hello World</app-message>
// Example with strict mode
let data = json!({"config": {"debug": true, "timeout": 30}});
let options = Some(Options {
indent: "".to_string(),
prefix: "".to_string(),
strict: true,
});
let result = llml(&data, options);
// Output: <config>
// <config-debug>true</config-debug>
// <config-timeout>30</config-timeout>
// </config>
// Example with strict mode disabled (default)
let options = Some(Options {
indent: "".to_string(),
prefix: "".to_string(),
strict: false,
});
let result = llml(&data, options);
// Output: <config>
// <debug>true</debug>
// <timeout>30</timeout>
// </config>
let complex_data = json!({
"user_config": {
"theme_mode": "dark",
"max_retries": 5
},
"data_sources": [
{"name": "db1", "active": true},
{"name": "db2", "active": false}
]
});
let result = llml(&complex_data, None);
// Produces nested XML-like structure with kebab-case keys
| Input | Output |
|---|---|
user_name |
user-name |
maxRetries |
max-retries |
key with spaces |
key-with-spaces |
Run the included examples to see LLML in action:
cargo run --example basic_usage
This will demonstrate:
Run the comprehensive test suite:
cargo test
The library includes extensive tests covering:
The library uses a recursive formatter that:
This is part of the LLML project. See the main repository for contribution guidelines.
MIT