From c07249c3f6bbd0cd80f962e52334e5d4c1467a59 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 22 Apr 2024 12:04:15 -0500 Subject: [PATCH] refactor(data): Make json branches consistent --- crates/snapbox/src/data/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/snapbox/src/data/mod.rs b/crates/snapbox/src/data/mod.rs index 72c48d2f..5442bfee 100644 --- a/crates/snapbox/src/data/mod.rs +++ b/crates/snapbox/src/data/mod.rs @@ -358,9 +358,10 @@ impl Data { } #[cfg(feature = "json")] (DataInner::Text(inner), DataFormat::Json) => { - match serde_json::from_str::(&inner) { - Ok(json) => Self::json(json), - Err(_) => Self::text(inner), + if let Ok(json) = serde_json::from_str::(&inner) { + Self::json(json) + } else { + Self::text(inner) } } #[cfg(feature = "json")]