walk-json-dir
This tool parses and aggregates JSON files from a specified directory (and its subdirectories) into a single output JSON file.
Installation
First, ensure you have Go installed. If not, go here.
Then run the following command:
go install github.com/skelouse/walk-json-dir@latest
Usage
walk-json-dir
provides the following options:
-dir
or -d
: Specifies the directory to search for JSON files. Default is the current directory (./
).
-output-file-path
or -o
: Specifies the path to the output JSON file. Default is output.json
in the current directory.
output all json files in current working directory and all subdirectories
walk-json-dir
output all json files in a provided directory
walk-json-dir -d <path/to/directory> -o <output/file/path>
Example
Assuming you have a directory structure as follows:
data/
config.json
users/
john.json
Contents:
{
"appVersion": "1.0.0",
"environment": "production"
}
{
"name": "John Doe",
"email": "[email protected]"
}
And you want to aggregate these JSON files into a single file named combined.json
, run:
walk-json-dir -r ./data -o combined.json
combined.json
{
"config": {
"appVersion": "1.0.0",
"environment": "production"
},
"users": {
"john": {
"email": "[email protected]",
"name": "John Doe"
}
}
}
Notes
- Expects all JSON files to have valid JSON formats.
- If you get an out of memory error: