Slide 21
Slide 21 text
serde
use actix_web::{HttpResponse, Responder};
use serve::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct User {
id: i32,
username: String,
name: String
}
async fn user_detail_json() -> imp Responder {
let user = User {
id: 12345,
username: “stefafafan”.to_string(),
name: “ͯ͢ʹΌΜ”.to_string(),
}
// ͜Εactix_webͷ͚ؔͩͲJSONͱͯ͠ฦͤͯΔ
HttpResponse::Ok().json(user)
}
Rust͚ʹσʔλΛSerialize/
Deserialize͢ΔϑϨʔϜϫʔΫ
https://github.com/serde-rs/
serde