我有 JSON,其中一个键有一个对象数组,我只对其中的一个字符串感兴趣:
{
"actors": [{
"name": "Bob",
"foo": "bar"
}, {
"name": "Jim",
"foo": "baz"
}],
"fruits": [{
"name": "Pineapple",
"foo": "bar"
}, {
"name": "Apple",
"foo": "baz"
}]
}
我有
use serde::Deserialize; // 1.0.110
#[derive(Deserialize)]
pub struct Name {
pub name: String,
}
#[derive(Deserialize)]
pub struct Data {
pub actors: Vec<Name>,
pub fruits: Vec<Name>,
}
我怎样才能把它弄平,这样我就可以拥有Vec<String>
而不是Vec<Name>
?例如我想结束
actors: ["Bob", "Jim"],
fruits: ["Pineapple", "Apple"],