From 359b77b5aa9745c8cb9afa8eb3b4dc0d979cdad8 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 15 Jun 2023 17:11:44 +0200 Subject: [PATCH] fix: should also work when it's not json --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8dfd50c..7268c59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,7 +169,11 @@ async fn main() -> Result<(), Box> { if args.verbose { let mut body = response.text().await?; if pretty { - body = serde_json::to_string_pretty(&serde_json::from_str::(&body)?)?; + if let Ok(v) = serde_json::from_str::(&body) { + if let Ok(t) = serde_json::to_string_pretty(&v) { + body = t; + } + } } println!(" │ {}", body.replace("\n", "\n │ ")); println!(" │");