extern crate serde_json; use std::path::PathBuf; /// The JSON configuration is **deprecated** and will be removed in the near future. /// Please migrate to the TOML configuration. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct JsonConfig { pub src: Option, pub dest: Option, pub title: Option, pub author: Option, pub description: Option, pub theme_path: Option, pub google_analytics: Option, } /// Returns a JsonConfig from a JSON string /// /// ``` /// # use mdbook::config::jsonconfig::JsonConfig; /// # use std::path::PathBuf; /// let json = r#"{ /// "title": "Some title", /// "dest": "htmlbook" /// }"#; /// /// let config = JsonConfig::from_json(&json).expect("Should parse correctly"); /// assert_eq!(config.title, Some(String::from("Some title"))); /// assert_eq!(config.dest, Some(PathBuf::from("htmlbook"))); /// ``` impl JsonConfig { pub fn from_json(input: &str) -> Result { let config: JsonConfig = serde_json::from_str(input) .map_err(|e| format!("Could not parse JSON: {}", e))?; return Ok(config); } }