Skip to main content

Crate jaml

Crate jaml 

Source
Expand description

A Rust library for parsing and formatting JAML (Just Another Markup Language).

JAML is a human-readable data serialization format similar to YAML but with explicit integer and binary types. It shares the same data model as JASN, providing a YAML-like syntax as an alternative to the JSON5-like JASN format.

§Features

  1. Explicit Integer Types: Distinguish between integers and floats (2 vs 2.0).
  2. Binary Data: Support for base64 and hex-encoded binary data
  3. Timestamps: ISO8601/RFC3339 timestamps
  4. YAML-inspired syntax: Indentation-based structure, cleaner appearance

§Usage

§AST Manipulation (no serde required)

use jaml::{parse, format};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let value = parse(r#"
name: "Alice"
age: 30
balance: 1234.56
data: b64"SGVsbG8="
tags:
  - "rust"
  - "yaml"
  - "parser"
    "#)?;
     
    println!("{:#?}", value);
     
    // Format back to JAML
    let formatted = format(&value);
    println!("{}", formatted);
    Ok(())
}

§Serde Integration (default feature)

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct Person {
    name: String,
    age: u32,
}

let person = Person { name: "Alice".into(), age: 30 };
let jaml_text = jaml::to_string(&person).unwrap();
let parsed: Person = jaml::from_str(&jaml_text).unwrap();

§Features

  • serde (default): Enable serde serialization/deserialization support

Re-exports§

pub use formatter::format;
pub use formatter::format_with_opts;
pub use de::from_str;
pub use de::from_value;
pub use ser::to_string;
pub use ser::to_string_pretty;
pub use ser::to_value;

Modules§

de
Deserialization of JAML text to Rust values.
formatter
Format a Value into JAML text.
ser
Serialization of Rust values to JAML text.

Structs§

Binary
A wrapper for Vec<u8>… at least until Rust supports specialization.

Enums§

ParseError
Errors that can occur during parsing.
Value
Represents a valid JASN value.

Functions§

parse
Parse a JAML string into a Value.

Type Aliases§

ParseResult
Result type for parsing operations.
Timestamp
Type alias for timestamps (RFC3339/ISO8601 compatible).