小编Ale*_*chi的帖子

jq json过滤器并保持原始结构

我对命令 jq 真的很陌生,我正在尝试进行一些过滤以删除我不想要/不需要的数据块。

这是我的 JSON 结构示例:

{
  "BackupCfg": [
    {
      "type": "filesystem",
      "repository": "trunk",
      "url": "test.example.com",
      "port": "394",
      "cfg": [
        {
          "Default": "true",
          "ID": "trunk00",
          "Paths": [
            "/etc",
            "/home",
            "/var",
            "/usr/local",
            "/opt",
            "/root"
          ],
          "Cron": "33 0 * * *"
        }
      ]
    },
    {
      "type": "filesystem",
      "repository": "trunk02",
      "url": "test.example.com",
      "port": "394",
      "cfg": [
        {
          "ID": "trunk01",
          "Paths": [
            "/opt/example",
            "/opt/var_example"
          ],
          "Cron": "*/30 0-23 * * *"
        }
      ]
    },
    {
      "type": "database",
      "repository": "trunk-db",
      "url": "test.example.com",
      "port": "399", …
Run Code Online (Sandbox Code Playgroud)

select json edit jq

5
推荐指数
1
解决办法
759
查看次数

标签 统计

edit ×1

jq ×1

json ×1

select ×1