walk-json-dir

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 11 Imported by: 0

README

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:

  • config.json
{
  "appVersion": "1.0.0",
  "environment": "production"
}
  • users/john.json
{
  "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:

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL