gpt4 book ai didi

json - 如何在不需要包装器类型的情况下反序列化 JSON 数组?

转载 作者:行者123 更新时间:2023-11-29 08:27:02 27 4
gpt4 key购买 nike

<分区>

我想反序列化以下 JSON:

[
{
"name": "one",
"path": "/path/to/one"
},
{
"name": "two",
"path": "/path/to/two"
},
{
"name": "three",
"path": "/path/to/three"
}
]

进入Vec<Worskpace> . Workspace定义如下:

#[derive(Serialize, Deserialize)]
struct Workspace {
name: String,
path: String,
}

有没有办法做到这一点而不必做类似的事情:

#[derive(Serialize, Deserialize)]
struct Workspacesss {
values: Vec<Workspace>,
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com