fn ascii() -> Result<(), Box<dyn std::error::Error>> {
let s = fs::read_to_string("../src/ascii.json")?;
let json_data: serde_json::Value = serde_json::from_str(&s)?;
println!("{}", json_data);
fs::write("../src/ascii.json", serde_json::to_string_pretty(&json_data)?)?;
Ok(())
}
use serde::{Deserialize, Serialize};
use serde_json::from_str;
use lazy_static::lazy_static;
#[derive(Serialize, Deserialize)]
struct Ascii {
ascii: Vec<String>,
}
lazy_static! {
static ref ASCII_DATA: Ascii = {
let file_contents = include_str!("ascii.json");
from_str(file_contents).expect("Could not deserialize JSON")
};
}
fn ascii() -> &'static Vec<String> {
&ASCII_DATA.ascii
}
fn main() {
let lines = ascii();
for line in lines {
println!("{}", line);
}
}