From 8a36a677c6d64cef852eb5f21bfcd5d661e034e3 Mon Sep 17 00:00:00 2001 From: puripuri2100 Date: Mon, 8 Apr 2024 20:09:18 +0900 Subject: [PATCH] fix --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1ce541e..b27c348 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,8 +81,11 @@ fn gen_jorei_url(id: &str) -> String { #[derive(Debug, Clone, Deserialize, Serialize)] struct JoreiInfoListResponseDocs { + #[serde(default)] collection: Vec, + #[serde(default)] collected_date: Vec, + #[serde(default)] updated_date: Vec, municipality_id: String, prefecture: Option, @@ -119,8 +122,11 @@ struct JoreiListResponse { #[derive(Debug, Clone, Deserialize, Serialize)] struct JoreiInfoDocs { + #[serde(default)] collection: Vec, + #[serde(default)] collected_date: Vec, + #[serde(default)] updated_date: Vec, municipality_id: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -153,8 +159,10 @@ struct JoreiInfoDocs { reiki_url: Option, has_version: bool, file_type: String, + #[serde(default)] h_type: Vec, - content: String, + #[serde(skip_serializing_if = "Option::is_none")] + content: Option, #[serde(skip_serializing_if = "Option::is_none")] collected_date_s: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -225,7 +233,7 @@ async fn main() -> Result<()> { let jorei_info: JoreiInfoResponse = client.get(&api_url).send().await?.json().await?; let docs = &jorei_info.response.docs[0]; write_docs(&args.output, id, docs).await?; - info!("done: {}({})", docs.title, docs.id); + info!("done: {}({}) at ({})", docs.title, docs.id, docs.clone().announcement_date_s.unwrap_or("None".to_string())); } // 負荷を抑えるために500ミリ秒待つ info!("sleep");