Skip to content

Commit

Permalink
Refactored response parsing to only include valuable info
Browse files Browse the repository at this point in the history
  • Loading branch information
holtkampjs committed Mar 12, 2023
1 parent 4898674 commit da41cfc
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#![allow(unused)]
use reqwest::Result;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

#[derive(Debug, Deserialize, Serialize)]
struct Definition {
source: String,
text: String,
note: Option<String>,
#[serde(rename(deserialize = "partOfSpeech"))]
part_of_speech: String,
}

#[derive(Debug, Deserialize, Serialize)]
struct ExampleUsage {
url: String,
title: String,
text: String,
id: i32,
}

#[derive(Debug, Deserialize, Serialize)]
struct WordOfTheDay {
#[serde(rename(deserialize = "contentProvider"))]
content_provider: HashMap<String, Value>,
definitions: Vec<HashMap<String, Value>>,
examples: Vec<HashMap<String, Value>>,
#[serde(rename(deserialize = "htmlExtra"))]
html_extra: Option<String>,
definitions: Vec<Definition>,
examples: Vec<ExampleUsage>,
note: String,
word: String,
}
Expand Down

0 comments on commit da41cfc

Please sign in to comment.