-
Notifications
You must be signed in to change notification settings - Fork 640
serde_json::from_value fails on sequence deserialization for a String array #871
Copy link
Copy link
Closed
Description
serde_json::from_value fails on sequence deserialization for a String array previously created by serde_json::to_value with invalid type: string \"...\", expected a borrowed string error. The reason is this code fragment
Lines 336 to 352 in 2733e63
| fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Error> | |
| where | |
| V: Visitor<'de>, | |
| { | |
| self.deserialize_string(visitor) | |
| } | |
| fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Error> | |
| where | |
| V: Visitor<'de>, | |
| { | |
| match self { | |
| #[cfg(any(feature = "std", feature = "alloc"))] | |
| Value::String(v) => visitor.visit_string(v), | |
| _ => Err(self.invalid_type(&visitor)), | |
| } | |
| } |
where 349 calls visitor.visit_string(v) while v is a StrVisitor and not StringVisitor object. This object fails to process String and not &str with the error above returned from here:
https://github.com/serde-rs/serde/blob/7e19ae8c9486a3bbbe51f1befb05edee94c454f9/serde/src/de/mod.rs#L1476-L1492
I do not familiar with serde/serde_json internals and can't propose a proper fix here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels