Skip to content

Commit

Permalink
refactor(data): Make json branches consistent
Browse files Browse the repository at this point in the history
Cherry pick of c07249c (assert-rs#287)
  • Loading branch information
epage committed May 15, 2024
1 parent d19b177 commit 2a1d5a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/snapbox/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,10 @@ impl Data {
}
#[cfg(feature = "json")]
(DataInner::Text(inner), DataFormat::Json) => {
match serde_json::from_str::<serde_json::Value>(&inner) {
Ok(json) => Self::json(json),
Err(_) => Self::text(inner),
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&inner) {
Self::json(json)
} else {
Self::text(inner)
}
}
#[cfg(feature = "term-svg")]
Expand Down

0 comments on commit 2a1d5a4

Please sign in to comment.