#json-file #json-array #json-path #split #id #maps #multiple

app json-split-aom

Split a large JSON file containing an array of maps into multiple files

5 releases

new 0.2.1 Dec 4, 2024
0.2.0 Oct 24, 2024
0.1.2 Aug 16, 2024
0.1.1 Jul 23, 2024
0.1.0 Sep 15, 2023

#1325 in Parser implementations

Download history 161/week @ 2024-08-16 2/week @ 2024-08-23 14/week @ 2024-09-13 11/week @ 2024-09-20 7/week @ 2024-09-27 3/week @ 2024-10-04 1/week @ 2024-10-11 68/week @ 2024-10-18 60/week @ 2024-10-25 5/week @ 2024-11-01 2/week @ 2024-11-08 94/week @ 2024-11-29

97 downloads per month

MIT license

8KB
131 lines

Usage

$ json-split-aom -h
Split a large JSON file containing an array of maps into multiple files

Usage: json-split-aom [OPTIONS] -a <JSON_PATH> -i <JSON_PATH> [FILES]...

Arguments:
  [FILES]...  Input file(s)

Options:
  -a <JSON_PATH>      Dotted JSON path to an array in the input file
  -i <JSON_PATH>      Dotted JSON path to the ID in the array element
  -p                  Pretty print output files
  -c                  Allow ID path collisions; still gives warnings but
                      duplicates will overwrite previous files
  -h, --help          Print help
  -V, --version       Print version

---

# Assumptions

* The JSON dotted path keys for array and ID don't have periods.

# Examples
    
1. Use `json-split-aom -a 'Apple.Banana' -i 'id' file.json` to extract objects
   to files named `Apple.Banana-id-ID.json` given a `file.json` with content:
   `{"Apple":{"Banana":[{"id":12,...},...]}}`

2. Use `json-split-aom -a 'Apple' -i 'Banana.id' file.json` to extract objects
   to files named `Apple-Banana.id-ID.json` given a `file.json` with content:
   `{"Apple":[{"Banana":{"id":12,...}},...]}`

3. Use `json-split-aom -a 'Apple.Banana' -i 'Cherry.id' file.json` to extract
   objects to files named `Apple.Banana-Cherry.id-ID.json` given a `file.json`
   with content: `{"Apple":{"Banana":[{"Cherry":{"id":12,...},...}]}}`
$ json-split-aom -V
json-split-aom 0.2.1

Dependencies

~3–12MB
~161K SLoC