diff --git a/README.md b/README.md index f2dfb0b77..edeccd743 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,12 @@ enum A { } ``` +## Advanced examples + +Some of the less trivial examples are present in [examples](./borsh/examples) folder: + +- [implementing `BorshSerialize`/`BorshDeserialize` for third-party `serde_json::Value`](./borsh/examples/serde_json_value.rs) + ## Testing Integration tests should generally be preferred to unit ones. Root module of integration tests of `borsh` crate is [linked](./borsh/tests/tests.rs) here. diff --git a/borsh/examples/serde_json_value.rs b/borsh/examples/serde_json_value.rs index 6a5dec57b..1c36cec8e 100644 --- a/borsh/examples/serde_json_value.rs +++ b/borsh/examples/serde_json_value.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use borsh::{BorshDeserialize, BorshSerialize}; -od serde_json_value { +mod serde_json_value { pub use de::deserialize_value; pub use ser::serialize_value; mod ser { @@ -246,6 +246,7 @@ struct SerdeJsonAsField { } fn main() { + // original code is from https://github.com/near/borsh-rs/pull/312 let original = serde_json::json!({ "null": null, "true": true,