openmina / mina-p2p-messages-rs

0 stars 0 forks source link

Fix: JSON deserialization #17

Closed adonagy closed 1 year ago

adonagy commented 1 year ago

I tried to deserialize a JSON struct of type MinaBaseProofStableV2 and got an error that serde was expecting a "stringified number". The JSON had indeed a stringified number in place, but it couldn't deserialize it.

I looked into it and saw a clippy error: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse

It seems that each time the method visit_string is implemented, we also need to implement visit_str and vice versa. After this fix, serde could deserialize the type just fine :)

@akoptelov This is a small fix but just in case I put it in a PR to keep things clean, please merge when you see fit :)