Some JSON bodies pass integers as strings.
{
"unit": "lovelace",
"quantity": "500000"
}
Here's the current struct for this (simplified):
#[derive(Deserialize)]
pub struct Amount {
pub unit: String,
pub quantity: String,
}
It must be changed to:
#[derive(Deserialize)]
pub struct Amount {
pub unit: String,
#[serde_hacks]
pub quantity: Integer,
}
Where Integer is our type alias for i128 and serde_hacks is the custom deserialization for that specific field.
Some options to customize this:
- https://docs.rs/serde_with/1.10.0/serde_with/#displayfromstr
- https://serde.rs/variant-attrs.html# (+ https://docs.rs/serde/1.0.130/serde/de/trait.Error.html)
Some JSON bodies pass integers as strings.
{ "unit": "lovelace", "quantity": "500000" }Here's the current struct for this (simplified):
It must be changed to:
Where
Integeris our type alias fori128andserde_hacksis the custom deserialization for that specific field.Some options to customize this: