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

如何从复杂对象数组中提取指定的表格列数组

提取目标列数组的方法

假设你需要提取的两个高亮列对应每个Rows元素中的特定属性(如果是嵌套结构则调整访问路径),可以通过两次map操作分别提取出两个独立的数组:

// 提取第一组高亮列的数组
const firstHighlightedColumn = Rows.map(row => row.targetCol1);
// 提取第二组高亮列的数组
const secondHighlightedColumn = Rows.map(row => row.targetCol2);

console.log("第一列数组", firstHighlightedColumn);
console.log("第二列数组", secondHighlightedColumn);

如果目标列数据嵌套在更深的层级里(比如每个行对象的table_cell数组中前两个元素的content字段),只需修改属性访问路径即可:

// 示例:假设高亮列是table_cell数组的第0和第1项的content
const firstColumn = Rows.map(row => row.table_cell[0].content);
const secondColumn = Rows.map(row => row.table_cell[1].content);

如果需要将两个列数组整合到一个对象中方便管理,也可以这样写:

const highlightedColumns = {
  columnOne: Rows.map(row => row.targetCol1),
  columnTwo: Rows.map(row => row.targetCol2)
};

console.log(highlightedColumns);

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 17:55:57