You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在JOLT转换结果中去除数组内的空/Null值?

JOLT转换后pim_network数组存在无效空条目,需保留有效IPv4条目

我使用一套复杂的JOLT转换规则处理数据后,结果中出现了空/Null值。输入、转换规则和完整结果数据量较大,核心问题集中在pim_network数组——数组中混入了2个仅含空asset_id的无效条目,这是第4次shift操作后的Null值导致的,当前数组内容如下:

"pim_network": [
    {
      "ifindex": 1,
      "ip_address": "127.0.0.1",
      "ip_subnet": 8,
      "description": "lo",
      "mac_address": "00:00:00:00:00:00",
      "asset_id": ""
    },
    {
      "asset_id": ""
    },
    {
      "ifindex": 2,
      "ip_address": "192.168.119.129",
      "ip_subnet": 24,
      "description": "ens33",
      "mac_address": "00:0c:29:02:b8:cd",
      "asset_id": ""
    },
    {
      "asset_id": ""
    },
    {
      "ifindex": 3,
      "ip_address": "172.17.0.1",
      "ip_subnet": 16,
      "description": "docker0",
      "mac_address": "02:42:36:ae:50:55",
      "asset_id": ""
    },
    {
      "ifindex": 4,
      "ip_address": "172.18.0.1",
      "ip_subnet": 16,
      "description": "br-c75ac7c3061d",
      "mac_address": "02:42:aa:97:1e:97",
      "asset_id": ""
    }
  ]

我需要调整转换规则,让最终结果仅保留4条有效的IPv4条目。

注:上述JSON格式排版不够规范,是JOLT演示网站的输出结果。

内容的提问来源于stack exchange,提问作者Marc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 20:22:39