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

在Logic App中解析消息后如何移除JSON中的指定节点

在Logic App中移除JSON节点的实现方法

问题场景

现有已解析的消息JSON:

{"date": "2022-02-04","customerID": 123,"customerInfo": {"id": 123,"lastname": "Smith","firstname": "David","email": "testing@email.com"},"currency": "EUR"}

需要移除其中的customerInfo节点,得到目标JSON:

{"date": "2022-02-04","customerID": 123,"currency": "EUR"}

尝试使用remove property工具未成功,求Logic App中的可行实现方法。


可行实现方法

方法1:用Select操作筛选保留字段

  • 在流程里添加Select操作
  • From选择原JSON对象(比如triggerBody()或者存储该JSON的变量)
  • 在Map区域手动添加要保留的字段:
    • date:映射值填item()?['date']
    • customerID:映射值填item()?['customerID']
    • currency:映射值填item()?['currency']
  • 运行后,Select的输出就是只包含指定字段的目标JSON

方法2:用Compose直接构造新JSON

  • 添加Compose操作,在输入框里直接写构造表达式:
    {
      "date": @{triggerBody()?['date']},
      "customerID": @{triggerBody()?['customerID']},
      "currency": @{triggerBody()?['currency']}
    }
    
  • 这种方式直接提取需要的字段重组,步骤简单,适合字段少的场景

方法3:Parse JSON后结构化引用

  1. 先加Parse JSON操作,输入原JSON生成对应的Schema
  2. 再添加Compose操作,用Parse后的结构化数据引用字段:
    {
      "date": @{body('Parse_JSON')?['date']},
      "customerID": @{body('Parse_JSON')?['customerID']},
      "currency": @{body('Parse_JSON')?['currency']}
    }
    
  • 适合原JSON结构复杂、需要多次复用字段的场景,引用更清晰

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 14:30:39