Skip to content

Commit ea823c1

Browse files
committed
fix(format): Correctly deserialize json5
Fixes #689
1 parent b4bc68f commit ea823c1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/file/format/json5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'de> serde::de::Deserialize<'de> for Val {
2525
.i64(|value| Ok(Self::Integer(value)))
2626
.f64(|value| Ok(Self::Float(value)))
2727
.string(|value| Ok(Val::String(value.to_owned())))
28-
.none(|| Ok(Self::Null))
28+
.unit(|| Ok(Self::Null))
2929
.seq(|value| value.deserialize().map(Val::Array))
3030
.map(|value| value.deserialize().map(Val::Object))
3131
.deserialize(d)

tests/testsuite/file_json5.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn test_file() {
1616
place: Place,
1717
#[serde(rename = "arr")]
1818
elements: Vec<String>,
19+
nullable: Option<String>,
1920
}
2021

2122
#[derive(Debug, Deserialize)]
@@ -54,6 +55,7 @@ fn test_file() {
5455
},
5556
FOO: "FOO should be overridden",
5657
bar: "I am bar",
58+
nullable: null
5759
}
5860
"#,
5961
FileFormat::Json5,
@@ -93,6 +95,7 @@ fn test_file() {
9395
"John Smith".to_owned()
9496
);
9597
}
98+
assert_eq!(s.nullable, None);
9699
}
97100

98101
#[test]

0 commit comments

Comments
 (0)