使用一行 pr 元素将 JSON 数组写入标准输出

Write JSON-array to stdout with one line pr element

我有一个 JSON 数组,我想用一个元素 pr 行写入 STDOUT,以便我们的日志记录工具 Grafana 可以更轻松地获取它。

# Our data
[
  {
    "PkgName": "perl-base",
    "Severity": "MEDIUM",
    "VulnerabilityID": "CVE-2020-16156",
    "InstalledVersion": "5.34.0-3ubuntu1",
    "FixedVersion": "",
    "Title": "perl-CPAN: Bypass of verification of signatures in CHECKSUMS files",
    "PrimaryURL": "https://avd.aquasec.com/nvd/cve-2020-16156",
    "namespace": "la",
    "image": ""
  },
  {
    "PkgName": "tar",
    "Severity": "LOW",
    "VulnerabilityID": "CVE-2019-9923",
    "InstalledVersion": "1.34+dfsg-1build3",
    "FixedVersion": "",
    "Title": "tar: null-pointer dereference in pax_decode_header in sparse.c",
    "PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-9923",
    "namespace": "la",
    "image": ""
  }
]

我需要的:

{"PkgName": "perl-base", "Severity": "MEDIUM", "VulnerabilityID": "CVE-2020-16156", "InstalledVersion": "5.34.0-3ubuntu1", "FixedVersion": "", "Title": "perl-CPAN: Bypass of verification of signatures in CHECKSUMS files", "PrimaryURL": "https://avd.aquasec.com/nvd/cve-2020-16156", "namespace": "la", "image": ""}
{"PkgName": "tar","Severity": "LOW","VulnerabilityID": "CVE-2019-9923","InstalledVersion": "1.34+dfsg-1build3","FixedVersion": "","Title": "tar: null-pointer dereference in pax_decode_header in sparse.c","PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-9923","namespace": "la","image": ""}

是否有使用 jq 或类似的 default ubuntu 工具实现此目的的简单方法?

运行 jq -c '.[]' 产生:

$ jq -c '.[]' data.json
{"PkgName":"perl-base","Severity":"MEDIUM","VulnerabilityID":"CVE-2020-16156","InstalledVersion":"5.34.0-3ubuntu1","FixedVersion":"","Title":"perl-CPAN: Bypass of verification of signatures in CHECKSUMS files","PrimaryURL":"https://avd.aquasec.com/nvd/cve-2020-16156","namespace":"la","image":""}
{"PkgName":"tar","Severity":"LOW","VulnerabilityID":"CVE-2019-9923","InstalledVersion":"1.34+dfsg-1build3","FixedVersion":"","Title":"tar: null-pointer dereference in pax_decode_header in sparse.c","PrimaryURL":"https://avd.aquasec.com/nvd/cve-2019-9923","namespace":"la","image":""}