Split a JSON file into separate files

前端 未结 3 1908
野性不改
野性不改 2020-12-03 17:52

I have a large JSON file that is an object of objects, which I would like to split into separate files name after object keys. Is it possible to achieve this using jq or any

3条回答
  •  广开言路
    2020-12-03 18:41

    Is it possible to achieve this using jq or any other off-the-shelf tools?

    It is. Xidel can also do what you want:

    for f in $(xidel -s input.json -e '$json()'); do
      xidel -s input.json -e '$json("'$f'")' > $f.json
    done
    

提交回复
热议问题