This question already has an answer here:
- How can I deserialize JSON with a top-level array using Serde? 1 answer
I want to deserialize the following JSON:
[
{
"name": "one",
"path": "/path/to/one"
},
{
"name": "two",
"path": "/path/to/two"
},
{
"name": "three",
"path": "/path/to/three"
}
]
Into a Vec<Worskpace>
. Workspace
is defined below:
#[derive(Serialize, Deserialize)]
struct Workspace {
name: String,
path: String,
}
Is there a way to do that without having to do something like:
#[derive(Serialize, Deserialize)]
struct Workspacesss {
values: Vec<Workspace>,
}