jtl-rs

Crates.iojtl-rs
lib.rsjtl-rs
version
sourcesrc
created_at2025-02-22 21:01:16.051564+00
updated_at2025-02-23 01:59:01.789989+00
descriptionA Rust library for parsing and stringifying JTL documents.
homepage
repositoryhttps://github.com/OrtheSnowJames/jtl-rs
max_upload_size
id1565791
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
James (OrtheSnowJames)

documentation

README

This project is licensed under the MIT License. See the LICENSE file for more details.

JTL

This is a port from the go version of jtl. JTL is a simple tag language with a "nicer" syntax. I made this because I thought xml was too boilerplate. Efficency.

To start with this, first add jtl to your project.

cargo add jtl

Second, use it.

use jtl;

Third, do something with it.

fn test_parse() {
    const SAMPLE_JTL: &str = r#"DOCTYPE=JTL
>>>ENV;
>>>foo=bar;
>>>BEGIN;
>key="value">element_id>$env:foo;
>>>END;"#;
    let parsed = parse(SAMPLE_JTL).expect("Parsing should succeed");
    assert!(!parsed.is_empty());

    // Check that the parsed element contains the expected fields.
    let element = parsed.get(0).unwrap();
    let obj = element.as_object().expect("Element should be an object");
    assert_eq!(obj.get("key").unwrap(), "value");
    assert_eq!(obj.get("KEY").unwrap(), "element_id");
    assert_eq!(obj.get("Content").unwrap(), "bar");
    assert_eq!(obj.get("Contents").unwrap(), "bar");
}

Latest Commit: Refactored to use vec with all of them instead of using key value inside a hashmap ex: from: HashMap String, Value { "foo": { "Content (or Contents)": "20" } }

to: Vec Value [ { "key": "foo", "Content (or Contents)": "20" } ] .

Tests Passed: As of 2/22/2025, 2nd commit

Commit count: 0

cargo fmt