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")]