From c6ee046a3ba1f68eb4ba5cb0378858a071e122d8 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Mon, 19 Apr 2021 18:25:55 +0300 Subject: Add serde example --- examples/serdeser.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/serdeser.rs (limited to 'examples/serdeser.rs') diff --git a/examples/serdeser.rs b/examples/serdeser.rs new file mode 100644 index 0000000..60d90b9 --- /dev/null +++ b/examples/serdeser.rs @@ -0,0 +1,17 @@ +use gradecoin::schema::Transaction; +use serde_json; + +pub fn main() { + + let tx = Transaction { + by: "fingerprint_of_some_guy".to_owned(), + source: "31415926535897932384626433832795028841971693993751058209749445923".to_owned(), + target: "fingerprint_of_some_guy".to_owned(), + amount: 2, + timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30), + }; + + let tx_string = serde_json::to_string(&tx).unwrap(); + + println!("{}", &tx_string); +} -- cgit v1.2.3-70-g09d2