json_strip_whitespace/
json_strip_whitespace.rs1use babbel_json::{FileDestination, FileSource, strip_whitespace};
2use std::path::Path;
3
4#[path = "common/utility.rs"]
5mod json_utility_lib;
6use json_utility_lib::get_json_file_list;
7
8fn process_json_file(file_path: &str) -> Result<(), String> {
10 let mut source = FileSource::new(file_path).map_err(|e| e.to_string())?;
11 let mut destination = FileDestination::new(
12 Path::new(file_path)
13 .with_extension("json_stripped")
14 .to_string_lossy()
15 .as_ref(),
16 )
17 .map_err(|e| e.to_string())?;
18
19 strip_whitespace(&mut source, &mut destination);
20 Ok(())
21}
22
23fn main() {
24 let json_files = get_json_file_list("files");
25 for file_path in json_files {
26 match process_json_file(&file_path) {
27 Ok(()) => println!("Successfully converted {}", file_path),
28 Err(e) => eprintln!("Failed to convert {}: {}", file_path, e),
29 }
30 }
31}