1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pub mod common;
pub mod process;

#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;

/// get all path
pub fn get_all_path(root: String) -> Vec<String> {
    common::common::get_all_local_path(root)
}
/// flat deep nested json
/// # Examples
/// ```
///    let path= "./test.json";
///    let js = read_file_as_txt(&path);
///    let res=flat_json(&js);
///     dbg!(res);
/// ```
pub fn read_file_as_txt(file: &str)->String {
    common::common::read_file_as_txt(file)
}
/// flat deep nested json
/// # Examples
/// ```
///    let path= "./test.json";
///    let js = read_file_as_txt(&path);
///    let res=flat_json(&js);
///     dbg!(res);
/// ```
pub fn flat_json(js:&str)->Vec<String>{
    process::flat_js::flat_json(js)
}

/// nest vec string back to origin
/// # Examples
///
/// ```
///   let path = "./data/test.json";
///   let js = read_file_as_txt(&path);
///   let data = flat_json(&js);
///   dbg!(data.clone());
///   let res=nest_json(&data);
///   dbg!(res);
/// ```
pub fn nest_json(data: &Vec<String>) -> String {
    process::nested_js::nest_json(data)
}