I'm working with a free-form JSON into which I'd like to store known structures. For example:
#[derive(Debug, Serialize)]
struct AnyData {
value: serde_json::Value,
}
#[derive(Debug, Serialize)]
struct Person {
name: String,
address: String,
}
I'd like to populate AnyData::value
with Person
. Is there a way without serialising Person
, deserialising it as Value
and then serialising the entire AnyData
as JSON?
This is a bit simplistic example but my restriction is that AnyData
doesn't know/care what is going to end up in value
.