I'm stuck, below is the JSON I get:
{
"BCH": {
"aclass": "currency",
"altname": "BCH",
"decimals": 10,
"display_decimals": 5
}
}
I'm a little confused about how my structure should look like to parse attributes using a box serde_json. Below is what I have:
#[derive(Deserialize, Debug)]
struct Assets {
aclass: String,
altname: String,
decimals: u8,
display_decimals: u8,
}
#[derive(Deserialize, Debug)]
struct Currency {
assest: Assets,
}
fn to_assets_type(value: serde_json::Value) -> Currency {
serde_json::from_value(value).unwrap()
}
The error message appears:
thread 'main' paniked at 'entitled Result::unwrap()to Errvalue: {ErrorImpl code: Message ( "missing field assest"), row 0, column: 0}', src / libcore / result.rs : 860: 4
BalaB source
share