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

Power Automate新手求助:提取嵌套JSON数据生成CSV/表格

解决Power Automate中嵌套JSON提取字段并转CSV/表格的问题

操作步骤

1. 定位目标数据数组

API返回的用户数据集中在results -> rows数组内,先通过表达式定位该数组作为后续操作的数据源:

body('你的API调用动作名称')?['results']?['rows']

2. 使用Select操作重构数据结构

添加Select动作,按以下配置:

  • From:输入上述表达式(或直接从动态内容面板选择对应数组)

  • 映射:手动添加需要提取的字段,每个字段对应如下表达式:

    • user_id: first(filter(item()?['columns'], item()?['name'] eq 'user_id'))?['value']
    • givenName: first(filter(item()?['columns'], item()?['name'] eq 'givenName'))?['value']
    • surname: first(filter(item()?['columns'], item()?['name'] eq 'surname'))?['value']
    • year: first(filter(item()?['columns'], item()?['name'] eq 'year'))?['value']
    • role: first(filter(item()?['columns'], item()?['name'] eq 'role'))?['value']

    👉 补充:如果担心部分字段不存在导致报错,可给表达式添加默认值,确保流稳定运行:

    coalesce(first(filter(item()?['columns'], item()?['name'] eq 'user_id'))?['value'], '')
    

    字段缺失时会返回空字符串,避免中断流执行。

3. 生成CSV或表格

添加Create CSV table动作:

  • From:选择Select动作的输出结果
  • Columns:选择「Custom」手动映射字段(或选「Automatic」让系统自动匹配),确认字段对应无误后,运行流即可生成标准CSV文件。

若需要HTML格式表格,替换为Create HTML table动作,配置逻辑完全一致。

示例效果

经过上述步骤后,Select动作会输出结构化的数组:

[
  {
    "user_id": "12345678",
    "givenName": "George",
    "surname": "Washington",
    "year": "1776",
    "role": "Incoming Student"
  }
]

最终生成的CSV内容为:

user_id,givenName,surname,year,role
12345678,George,Washington,1776,Incoming Student

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 07:52:57