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

使用JOLT提取REST API返回JSON指定层级的id字段

JOLT 转换配置方案

输入示例

{
  "status": "success",
  "textblocks": {
    "title": "Hello",
    "desc": "World"
  },
  "content": {
    "section1": {
      "id": "sec1",
      "name": "Section One",
      "data": {}
    },
    "section2": {
      "id": "sec2",
      "name": "Section Two",
      "data": {}
    }
  },
  "urls": {
    "home": {
      "id": "url_home",
      "path": "/",
      "params": {}
    },
    "about": {
      "id": "url_about",
      "path": "/about",
      "params": {}
    }
  }
}

正确JOLT转换规则

[
  {
    "operation": "shift",
    "spec": {
      "status": "status",
      "textblocks": "textblocks",
      "content": {
        "*": {
          "id": "content.&1"
        }
      },
      "urls": {
        "*": {
          "id": "urls.&1"
        }
      }
    }
  }
]

规则说明

  • 直接映射status和textblocks字段,完整保留原有内容。
  • 针对content字段,通过*匹配所有一级子对象,用&1引用子对象的原键名,仅提取子对象的id值并映射到content.原键名下。
  • urls字段采用与content完全一致的处理逻辑,提取每个一级子对象的id并保留原键名。

预期输出

{
  "status": "success",
  "textblocks": {
    "title": "Hello",
    "desc": "World"
  },
  "content": {
    "section1": "sec1",
    "section2": "sec2"
  },
  "urls": {
    "home": "url_home",
    "about": "url_about"
  }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 15:26:33