serde_tjs

Crates.ioserde_tjs
lib.rsserde_tjs
version0.1.1
created_at2025-11-20 06:05:47.41816+00
updated_at2025-11-20 06:30:44.759491+00
descriptionA Serde serialization/deserialization library for TJS2 data.
homepage
repositoryhttps://github.com/lifegpc/serde_tjs
max_upload_size
id1941174
size66,580
(lifegpc)

documentation

README

Serde TJS

A Serde serialization/deserialization library for TJS2 data.

use serde::{Deserialize, Serialize};
use serde_tjs::Result;

#[derive(Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
    phones: Vec<String>,
}

fn typed_example() -> Result<()> {
    // Some TJS2 input data as a &str. Maybe this comes from the user.
    let data = r#"
        (const) %[
            "name" => "John Doe",
            "age" => 43,
            "phones" => (const) [
                "+44 1234567",
                "+44 2345678"
            ]
        ]"#;

    // Parse the string of data into a Person object. This is exactly the
    // same function as the one that produced serde_tjs::Value above, but
    // now we are asking it for a Person as output.
    let p: Person = serde_tjs::from_str(data)?;

    // Do things just like with any other Rust data structure.
    println!("Please call {} at the number {}", p.name, p.phones[0]);

    Ok(())
}
Commit count: 0

cargo fmt