I have a JSON object that contains a string that itself is a JSON object. How can I deserialize it?
I'd like to be able to do something like:
#[derive(Deserialize)]
struct B {
c: String,
d: u32,
}
#[derive(Deserialize)]
struct Test {
a: String,
b: B,
}
let object: Test = serde_json::from_str(
r#"
{
"a": "string",
"b": "{\"c\":\"c_string\",\"d\":1234}"
}
"#,
)
.unwrap();
But this panics with invalid type: string "{\"c\":\"c_string\",\"d\":1234}", expected struct B