feat: update serde json
This commit is contained in:
@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Result, Value};
|
||||
use chrono::{DateTime, Utc, TimeZone};
|
||||
|
||||
// alternative JSON for human: https://crates.io/crates/json5
|
||||
mod my_date_format {
|
||||
use chrono::{DateTime, Utc, TimeZone};
|
||||
use serde::{self, Deserialize, Serializer, Deserializer};
|
||||
@@ -50,6 +51,8 @@ struct TestStruct {
|
||||
struct TestStruct2 {
|
||||
test_id: i32,
|
||||
test_name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
test_description: Option<String>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -91,6 +94,7 @@ fn main() -> Result<()> {
|
||||
let test_struct2 = TestStruct2 {
|
||||
test_id: 1,
|
||||
test_name: "Hatter".into(),
|
||||
test_description: None,
|
||||
};
|
||||
println!("{}", serde_json::to_string(&test_struct2)?);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user