Function oauth2::helpers::deserialize_space_delimited_vec
source · pub fn deserialize_space_delimited_vec<'de, T, D>(
deserializer: D
) -> Result<T, D::Error>where
T: Default + Deserialize<'de>,
D: Deserializer<'de>,Expand description
Serde space-delimited string deserializer for a Vec<String>.
This function splits a JSON string at each space character into a Vec<String> .
Example
In example below, the JSON value {"items": "foo bar baz"} would deserialize to:
GroceryBasket {
items: vec!["foo".to_string(), "bar".to_string(), "baz".to_string()]
};Note: this example does not compile automatically due to Rust issue #29286.
use serde::Deserialize;
#[derive(Deserialize)]
struct GroceryBasket {
#[serde(deserialize_with = "helpers::deserialize_space_delimited_vec")]
items: Vec<String>,
}