#weird json
10 messages · Page 1 of 1 (latest)
@sharp marten look above
Serde will automatically choose the correct enum based on the type
Value, or make your own enum
#[derive(Serialize, Deserialize)]
enum MyApiResult {
MYSTRING(String),
MYNUMBER(i32),
}
#[derive(Serialize, Deserialize)]
struct MyApiResult: {
apikey: MyApiResult
}
serde_json::from_str::<MyApiResult>(jsonstring);
you need #[serde(untagged)]
Oh yeah and that