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

Azure Logic Apps中动态移除请求体指定字段的实现方法

在Azure Logic Apps中动态移除指定字段并保留其余字段

场景说明

工作流数据源来自body('List_rows_present_in_a_table')?['value'],原始数据结构如下:

[
  {
    "@odata.etag": "",
    "ItemInternalId": "bf73ba98-d392-424c-9dc1-f2be44e9d431",
    "Name": "Shuvendu",
    "Dept": "Developer"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "3de1725d-d7cb-45fa-9855-713bbf8fdc23",
    "Name": "Debashish",
    "Dept": "DBA"
  }
]

需要动态移除@odata.etag和ItemInternalId字段,保留包括后续新增字段在内的所有其他字段,最终输出结构如下:

[
  {
    "Name": "Shuvendu",
    "Dept": "Developer"
  },
  {
    "Name": "Debashish",
    "Dept": "DBA"
  }
]

解决方案

使用Azure Logic Apps内置表达式,通过select与removeProperty函数组合实现动态字段移除:

核心表达式

select(body('List_rows_present_in_a_table')?['value'], removeProperty(removeProperty(item(), '@odata.etag'), 'ItemInternalId'))

操作步骤

  1. 在工作流中添加Compose动作(或直接在需要使用处理后数据的目标动作中调用该表达式)
  2. 将上述表达式粘贴到Compose的「输入」框内
  3. 运行工作流后,Compose的输出即为处理后的目标数组

表达式说明

  • select(body('List_rows_present_in_a_table')?['value'], ...):遍历源数组的每一个元素
  • item():指代当前遍历到的数组对象
  • removeProperty(item(), '@odata.etag'):移除当前对象中的@odata.etag字段
  • 嵌套的removeProperty(..., 'ItemInternalId'):在移除@odata.etag的基础上,继续移除ItemInternalId字段

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 21:40:01