Crates.io | dir_tree |
lib.rs | dir_tree |
version | 0.1.4 |
source | src |
created_at | 2024-06-26 05:20:03.251304 |
updated_at | 2024-06-26 08:59:21.75835 |
description | Walk a directory and convert to json object |
homepage | |
repository | https://github.com/sakgoyal/dir_tree |
max_upload_size | |
id | 1284173 |
size | 3,915 |
Generate a JSON tree based on the provided path
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"
]
}"#);