When trying to deserialize this string: json {"verification_token": "c2e82f6c-45b1-459d-aad7-d835fdf7430b", "message_id": "dd7ef772-4778-4a2f-bad5-947857f25cf9", "timestamp": "2022-11-18T09:07:20Z", "type": "Donation", "is_public": true, "from_name": "Ko-fi Team", "message": "Good luck with the integration!", "amount": "3.00", "url": "https://ko-fi.com/Home/CoffeeShop?txid=00000000-1111-2222-3333-444444444444", "email": "[email protected]", "currency": "USD", "is_subscription_payment": false, "is_first_subscription_payment": false, "kofi_transaction_id": "00000000-1111-2222-3333-444444444444", "shop_items": null, "tier_name": null, "shipping": null}
into this struct:
#[derive(serde::Deserialize, serde::Serialize, Debug)]
struct Payment {
verification_token: String,
message_id: String,
timestamp: String,
#[serde(rename = "type")]
type_: String,
is_public: bool,
from_name: String,
message: String,
amount: f64,
url: String,
email: String,
currency: String,
is_subscription_payment: bool,
is_first_subscription_payment: bool,
kofi_transaction_id: String,
}
I get the error:
Error("expected value", line: 1, column: 23)
I googled for this issue and found that this can be the case when the value in the JSON string can't be parsed as the type in the struct, but surely it should be ok to be parsed as a string?