Created
July 18, 2018 08:47
-
-
Save pimeys/ed98f2eda3234797b20d5b7c43265df5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate serde; | |
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde_json; | |
use std::fs::File; | |
use std::io::Write; | |
#[derive(Serialize)] | |
struct Foo { | |
bar: &'static str, | |
} | |
fn main() { | |
let foo = Foo { bar: "lol" }; | |
let mut file = File::create("foo.json").unwrap(); | |
file.write_all(&serde_json::to_vec(&foo).unwrap()).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment