json
json copied to clipboard
Uuid Serialization & Deserialization Error : expected ident at line 1 column 2
I have a HashMap<String, String> That is storing data as such:
{'uuid': 'f4a9a11b-6e71-443d-9289-71a26fe6a018'}
When I use:
let data = self.session_data.get("uuid");
if data.is_none()
{
return 0;
}
let test_uuid: Uuid = serde_json::from_str(data.unwrap().as_str())?;
I get the error:
expected ident at line 1 column 2
And I have no earthly idea why.
Why do you expect a JSON library to parse a third party type (Uuid) ?
You can use let test_uuid: Uuid = data.unwrap().parse().unwrap()
instead.