dir_tree

Crates.iodir_tree
lib.rsdir_tree
version0.1.4
sourcesrc
created_at2024-06-26 05:20:03.251304
updated_at2024-06-26 08:59:21.75835
descriptionWalk a directory and convert to json object
homepage
repositoryhttps://github.com/sakgoyal/dir_tree
max_upload_size
id1284173
size3,915
Saksham Goyal (sakgoyal)

documentation

README

dir_tree

Generate a JSON tree based on the provided path

Example

File structure:

/
L src/
    L lib.rs
let res = generate_directory_tree("./src");
assert_eq!(serde_json::to_string(&res), r#"{"/":["lib.rs"]}"#);

File structure:

/
L src/
    L baz/
        L page.rs
    L foo/
        L bar/
            L page.rs
        L page.rs
    L 404.rs
    L layout.rs
    L page.rs
let res = generate_directory_tree("./src");
assert_eq!(serde_json::to_pretty_string(&res), r#"
{
  "/": [
    "404.rs",
    "layout.rs",
    "page.rs"
  ],
  "/baz": [
    "page.rs"
  ],
  "/foo": [
    "page.rs"
  ],
  "/foo/bar": [
    "page.rs"
  ]
}"#);
Commit count: 6

cargo fmt