From 9df32232aa5ced1019a15dd7bc7c7546910e84c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Tue, 29 Oct 2024 16:15:31 +0200 Subject: [PATCH] doc: add reference in README.md --- README.md | 6 ++++++ borsh/examples/serde_json_value.rs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) 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,