jsonld-serialization 0.24.0

JSON-LD serialization
Documentation
#![allow(clippy::expect_used)]
use contextual::WithContext;
use jsonld_serialization::serialize;
use jstrict::Print;

#[derive(ld_core::Serialize)]
#[ld(prefix("ex" = "http://example.org/"))]
struct Foo {
    #[ld("ex:name")]
    name: String,

    #[ld("ex:email")]
    email: String,
}

fn main() {
    let value = Foo {
        name: "John Smith".to_string(),
        email: "john.smith@example.org".to_string(),
    };

    let json = serialize(&value).expect("serialization failed");
    eprintln!("{}", json.with(&()).pretty_print());
}