use super::*; pub fn deserialize_json<'a, T: de::Deserialize<'a>>( arg: &'a str, ) -> Result { serde_json::from_str(arg).map_err(|e| VeilidAPIError::ParseError { message: e.to_string(), value: String::new(), }) } pub fn deserialize_opt_json( arg: Option, ) -> Result { let arg = arg.ok_or_else(|| VeilidAPIError::ParseError { message: "invalid null string".to_owned(), value: String::new(), })?; deserialize_json(&arg) } pub fn serialize_json(val: T) -> String { serde_json::to_string(&val).expect("failed to serialize json value") }