fix: should also work when it's not json

This commit is contained in:
əlemi 2023-06-15 17:11:44 +02:00
parent afda46073a
commit 359b77b5aa
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -169,7 +169,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
if args.verbose {
let mut body = response.text().await?;
if pretty {
body = serde_json::to_string_pretty(&serde_json::from_str::<serde_json::Value>(&body)?)?;
if let Ok(v) = serde_json::from_str::<serde_json::Value>(&body) {
if let Ok(t) = serde_json::to_string_pretty(&v) {
body = t;
}
}
}
println!("{}", body.replace("\n", "\n"));
println!("");