Joined 9 years ago
> import json > with open("config.json") as f: > contents = f.read() > config = json.loads(contents)
extern crate serde_json as json; fn read_json() -> Result<json::Value, Box<std::error::Error>> { let file = std::fs::File::open("config.json")?; let config = json::from_reader(&file)?; Ok(config) }
> import configparser > config = ConfigParser() > config.read("config.conf")
extern crate config; use config::{Config, File, FileFormat}; fn read_config() -> Result<Config, Box<std::error::Error>> { let mut c = Config::new(); c.merge(File::new("config", FileFormat::Json))?; Ok(c) }