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

AWS Glue Crawler爬取嵌套JSON仅生成单行多列问题咨询

问题解答

1. JSON格式合规性判断

你提供的JSON语法完全合规,不存在格式错误。但它的数据结构不符合AWS Glue Crawler默认识别多行列数据的规则:当前JSON顶层是单个对象,sammy、jesse这类键都会被Glue识别为单独的列,所以最终爬取结果只有1行多列。

2. 格式调整方案

你确实需要调整JSON结构,最简便的方式是改为数组格式,把每条用户数据作为数组的独立元素,如果需要保留原来的顶层键(sammy等标识),可以将其作为每条数据的新增字段,调整后的参考格式如下:

[
  {
    "user_key": "sammy",
    "username": "SammyShark",
    "location": "Indian Ocean",
    "online": true,
    "followers": 987
  },
  {
    "user_key": "jesse",
    "username": "JesseOctopus",
    "location": "Pacific Ocean",
    "online": false,
    "followers": 432
  },
  {
    "user_key": "drew",
    "username": "DrewSquid",
    "location": "Atlantic Ocean",
    "online": false,
    "followers": 321
  },
  {
    "user_key": "jamie",
    "username": "JamieMantisShrimp",
    "location": "Pacific Ocean",
    "online": true,
    "followers": 654
  }
]

调整后Glue Crawler会自动将数组内的每个元素识别为单独的数据行,就能得到预期的多条数据结果。
如果无法修改API返回的原始结构,也可以在数据写入S3的环节通过Lambda等服务做一次格式转换,不需要调整API侧逻辑。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 12:36:04