| Crates.io | json2dir |
| lib.rs | json2dir |
| version | 0.1.0 |
| created_at | 2025-08-06 17:46:46.214486+00 |
| updated_at | 2025-08-06 17:46:46.214486+00 |
| description | Tool that converts JSON objects to directory trees |
| homepage | |
| repository | https://github.com/alurm/json2dir |
| max_upload_size | |
| id | 1784115 |
| size | 46,599 |
json2dir: a tool that converts JSON objects to directory trees, an alternative to home-manager
TL;DR:
file.json:
{
"file": "Hello, world!",
"dir": {
"subfile": "Content.\n",
"subdir": {}
},
"symlink": ["link", "target path"],
"script": ["script", "#!/bin/sh\necho Howdy!"]
}
cat file.json | json2dir
Here, four files will be added to the current directory: file, dir, symlink, and script.
Using json2dir as a home-manager alternative.
["link", target] represent symlinks, second element representing the target of the symlink.["script", content] represent executable files, second representing the content of the script.Regular JSON constraints apply. In particular, the input must be UTF-8. Currently, there's no way to represent files containing non-UTF-8 content.
When using this utility to create files for other users, care must be taken in order to prevent TOCTOU (time of check, time of use) attacks (e.g. with symlinks).
flake.nix contains a Nix package for json2dir.
To build the project, run cargo build or nix build. If you're using rustup, rust-toolchain.toml is provided.
Useful scripts may be found in the scripts folder.
A Nix cache is available at https://json2dir.cachix.org.
Feel free to fork/open issues/submit PRs/etc.