let mut person: Person = get_value_from_user();
if let Some(Value::Object(obj)) = &mut person.details {
obj.extend([ // note: requires fairly recent (stable) Rust, otherwise arrays are not `IntoIterator`
("channel".to_owned(), "web".into()),
("version".to_owned(), "1.0.1".into()),
]);
}
This will leave person unmodified unless the details field matches Some(Value::Object(_)). It will also replace existing entries whose key is "channel" or "version", if there are any.
Most likely there's a better (more idiomatic and less of a pain to work with) solution here where you take advantage of Serde to deserialize into your own struct instead of a weakly-typed Value.