In Rust this is just
#[derive(Serialize, Deserialize)]
struct MyStruct {
// ...
}

serde_json::to_string(&my_struct);