diff --git a/json/src/lib.rs b/json/src/lib.rs index c7880c3b2..6d1f5da48 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -39,6 +39,24 @@ //! ] //! } //! ``` +//! If we assume that FirstName is optional and all other fields are mandatory, the above JSON could correspond to the following Rust structs: +//! ```rust +//! #[derive(Serialize, Deserialize)] +//! struct Data { +//! FirstName: Option, +//! LastName: String, +//! Age: u32, +//! Address: Address, +//! PhoneNumbers: Vec +//! } +//! +//! #[derive(Serialize, Deserialize)] +//! struct Address { +//! Street: String, +//! City: String, +//! Country: String +//! } +//! ``` //! //! # Type-based Serialization and Deserialization //!