Skip to content

Commit

Permalink
refactor(data): Make json branches consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 22, 2024
1 parent 37816dd commit c07249c
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 @@ -358,9 +358,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 = "json")]
Expand Down

0 comments on commit c07249c

Please sign in to comment.