LoginSignup
11
4

More than 3 years have passed since last update.

【jq】JSON と ndjson の変換

Posted at

JSON から ndjson への変換

data.json
[
  {
    "id": 111,
    "value1": "aaa"
  },
  {
    "id": 222,
    "value1": "bbb"
  }
]
変換
jq -c '.[]' data.json
結果
{"id":111,"value1":"aaa"}
{"id":222,"value1":"bbb"}

ndjson から JSON への変換

data.ndjson
{"id":111,"value1":"aaa"}
{"id":222,"value1":"bbb"}
変換
jq -s '.' data.ndjson
結果
[
  {
    "id": 111,
    "value1": "aaa"
  },
  {
    "id": 222,
    "value1": "bbb"
  }
]

参考

jq Manual (development version)
https://stedolan.github.io/jq/manual/#Invokingjq

11
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
4