json icon indicating copy to clipboard operation
json copied to clipboard

Uuid Serialization & Deserialization Error : expected ident at line 1 column 2

Open WarrenN1 opened this issue 1 year ago • 2 comments

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.

WarrenN1 avatar Jun 14 '23 04:06 WarrenN1

Why do you expect a JSON library to parse a third party type (Uuid) ?

martin-g avatar Jun 14 '23 06:06 martin-g

You can use let test_uuid: Uuid = data.unwrap().parse().unwrap() instead.

tbu- avatar Jun 20 '23 16:06 tbu-