• Ivy Seo

JSON - write .txt file in Rust

pub fn serialize_writeFile(data : &full_data ) -> Result<bool, modbus::Error> { // 1) takes data 
 // this function takes the m7_data object and serializes the contents and saves the results to a text file
 // 2) serializes the contents
 let some_data = json!({

 "logdate" : Utc::now().naive_local(), 
 "direction": data.job_info.direction,
 "job": data.job_info.job_name
 // 3) saves the results to a text file

 let file_generated = File::create("C:/Users/Desktop/jsonData.txt").expect("create .txt file failed"); // file location

 let mut file_generated = BufWriter::new(file_generated);
 file_generated.write_all(format!("{}", some_data).as_bytes()).expect("write failed");


Recent Posts

See All

Generate unique filename: UUID, Path

A: using UUID let my_uuid = Uuid::new_v4(); let file_created = File::create(my_uuid.to_string()).expect("create file failed");     println!("uuid: {}", my_uuid); //  buffer write let mut file_ge

Serialize/Deserialize JSON in Rust

This README has some good examples. To deserialize in Rust: use serde::{Deserialize, Serialize}; use serde_json::Result; #[derive(Serialize, Deserialize)] struct Person {     name: String,     age: u

ngx-datatable ver. 1

How is how I created a data table : component.html file: <p style="font-weight: bold; font-size: larger; color: yellow;"> M7 Log Data Report </p> <ngx-datatable class="ngx-datatable" style= " border-s