// this JSON will have comments, thus invalid
{
"ok": true,
"error_code": 404, // if "ok" is false. can be absent.
"description": null, // if "ok" is false. can be null.
"result": { ... } // if "ok" is true. it has types.
}
result key has possible types, one of which is User. Assuming I derive Deserialize for a User struct I create as below:
#[derive(Deserialize)]
struct User {
// fields of User here, see link above
}
If there's no indication (besides structure) of result's type, you can use the untagged enum representation. This will try deserializing to each variant in turn until a matching one is found: