json
json copied to clipboard
Add a `from_value_ref` function to deserialize structs with `#[serde(borrow)]`
I'm not 100% sure such an idea would work, but here's the problem I'm having:
#[derive(Deserialize)]
struct Foo<'a> {
#[serde(borrow)]
inner: &'a str,
}
If I want to deserialize such a struct, and the JSON contains escaped characters, serde_json can't replace the escape sequences with the correct characters.
What if I first deserialized to a serde_json::Value, then deserialized from that to my target struct?