mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
fix: added a dedicated test to confirm that serde_json correctly handles JSON strings with leading and trailing whitespace (#15789)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -8250,6 +8250,7 @@ dependencies = [
|
||||
"pin-project",
|
||||
"rand 0.9.0",
|
||||
"reth-tracing",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.12",
|
||||
"tokio",
|
||||
|
||||
@@ -32,5 +32,6 @@ interprocess = { workspace = true, features = ["tokio"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio-stream = { workspace = true, features = ["sync"] }
|
||||
serde.workspace = true
|
||||
reth-tracing.workspace = true
|
||||
rand.workspace = true
|
||||
|
||||
@@ -300,4 +300,18 @@ mod tests {
|
||||
assert_eq!(request, "{ test: 1 }");
|
||||
assert_eq!(request2, "{ test: 2 }");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serde_json_accepts_whitespace_wrapped_json() {
|
||||
let json = " { \"key\": \"value\" } ";
|
||||
|
||||
#[derive(serde::Deserialize, Debug, PartialEq)]
|
||||
struct Obj {
|
||||
key: String,
|
||||
}
|
||||
|
||||
let parsed: Result<Obj, _> = serde_json::from_str(json);
|
||||
assert!(parsed.is_ok(), "serde_json should accept whitespace-wrapped JSON");
|
||||
assert_eq!(parsed.unwrap(), Obj { key: "value".into() });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user