I have a JSON object:
{ "min": 2, "max": 15 }
I'd like to parse it to this tuple struct:
#[derive(Serialize, Deserialize, Debug)]
struct TeamSize(pub i64, pub i64);
#[derive(Serialize, Deserialize, Debug)]
struct Match {
size: TeamSize,
}
The current Serde serialization mechanism does not seem to provide the functionality of (de)serializing a tuple structure from named values instead of an array.
The generated (de)serialization mechanism expects the following:
{"size": [2, 15]}
I've tried to use Serde attributes, but I can't find one that does what I want:
#[derive(Serialize, Deserialize, Debug)]
pub struct TeamSize(
#[serde(rename = "min")]
pub i64,
#[serde(rename = "max")]
pub i64
);
How to parse it? Should I implement everything by myself?
I've opened an issue on the Serde repository.