#Help with type encoding for JSON file
4 messages · Page 1 of 1 (latest)
4 messages · Page 1 of 1 (latest)
Hi , I',m trying to parse a json file with serde_json and I'm currently typing a field as a so
scope:Vec<String>
but the issue is that the file I'm parsing could be in any of these two forms
{
scope:"some_scope"
}
// or
{
scope:["multiple","possible","scopes"]
}
Is there any way I can handle this ?
have scope be an enum that contains either a String or a Vec<String>
then you could use a From conversion to make it just a single Vec
How would that look please ?