massa
massa copied to clipboard
Harmonize JSON response output for enums/structs
Actually, enum are serialized with Rust name :
{
"content": {
...
"op": {
"Transaction": {
"amount": "0.000950028",
"recipient_address": "A1Czd9sRp3mt2KU9QBEEZPsYxRq9TisMs1KnV4JYCe7Z4AAVinq"
}
}
},
...
}
It should be in snake case :
{
"content": {
...
"op": {
"transaction": {
"amount": "0.000950028",
"recipient_address": "A1Czd9sRp3mt2KU9QBEEZPsYxRq9TisMs1KnV4JYCe7Z4AAVinq"
}
}
},
...
}
Solution :
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OperationType {
/// transfer coins from sender to recipient
Transaction {
/// recipient address
recipient_address: Address,
/// amount
amount: Amount,
},
...
}