修复资源 kind 转义字符串反序列化
为 AssetKindVisitor 增加 visit_string 转发。 补充 JSON 转义 kind 的反序列化回归测试。
This commit is contained in:
@@ -192,6 +192,13 @@ impl<'de> Deserialize<'de> for GameCreationAppAssetKind {
|
||||
{
|
||||
Ok(GameCreationAppAssetKind::parse_with_context(value, "serde"))
|
||||
}
|
||||
|
||||
fn visit_string<E>(self, value: String) -> Result<Self::Value, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
self.visit_str(&value)
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_str(AssetKindVisitor)
|
||||
@@ -242,4 +249,12 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escaped_wire_strings_are_deserialized() {
|
||||
assert_eq!(
|
||||
serde_json::from_str::<GameCreationAppAssetKind>(r#""ui\u002Ddesign""#).unwrap(),
|
||||
GameCreationAppAssetKind::Unknown
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user