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

app json-split-aom

将包含数组映射的大型JSON文件分割成多个文件

3个版本

0.1.2 2024年8月16日
0.1.1 2024年7月23日
0.1.0 2023年9月15日

#3 in #json-array

Download history 130/week @ 2024-07-22 153/week @ 2024-08-12

每月 283 次下载

MIT 协议

8KB
122

用法

$ 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.1.2

依赖项

~3–15MB
~169K SLoC