【发布时间】:2015-09-03 18:00:22
【问题描述】:
我们在 node.js 中有一个以下格式的对象数组,我们希望这个数组在多维数组中。
对象数组:
[ { id: 4,
process_id: 94,
process_type: 'Section',
process_type_order: 1,
attribute_id: 6,
attribute_label: 'level4',
attribute_order: 1,
attribute_name: 'level4_1'
{ id: 4,
process_id: 94,
process_type: 'Section',
process_type_order: 1,
attribute_id: 7,
attribute_label: 'level5',
attribute_order: 2,
attribute_name: 'level5_1'
{ id: 15,
process_id: 94,
process_type: 'Section',
process_type_order: 2,
attribute_id: null,
attribute_label: null,
attribute_order: null,
attribute_name: null },
{ id: 5,
process_id: 94,
process_type: 'Section',
process_type_order: 3,
attribute_id: 8,
attribute_label: 'level6',
attribute_order: 1,
attribute_name: 'level6_1'
{ id: 5,
process_id: 94,
process_type: 'Section',
process_type_order: 3,
attribute_id: 9,
attribute_label: 'level7',
attribute_order: 2,
attribute_name: 'level7_1'
{ id: 6,
process_id: 94,
process_type: 'Section',
process_type_order: 4,
attribute_id: 10,
attribute_label: 'level8',
attribute_order: 1,
attribute_name: 'level8_1'
{ id: 14,
process_id: 94,
process_type: 'Section',
process_type_order: 5,
attribute_id: null,
attribute_label: null,
attribute_order: null,
attribute_name: null } ]
我们希望这个对象数组采用以下格式(多维数组)。请建议我们如何将其转换为以下格式
[ [ { id: 4,
process_id: 94,
process_type: 'Section',
process_type_order: 1,
attribute_id: 6,
attribute_label: 'level4',
attribute_order: 1,
attribute_name: 'level4_1' },
{ id: 4,
process_id: 94,
process_type: 'Section',
process_type_order: 1,
attribute_id: 7,
attribute_label: 'level5',
attribute_order: 2,
attribute_name: 'level5_1' } ],
[ { id: 15,
process_id: 94,
process_type: 'Section',
process_type_order: 2,
attribute_id: null,
attribute_label: null,
attribute_order: null,
attribute_name: null } ],
[ { id: 5,
process_id: 94,
process_type: 'Section',
process_type_order: 3,
attribute_id: 8,
attribute_label: 'level6',
attribute_order: 1,
attribute_name: 'level6_1' },
{ id: 5,
process_id: 94,
process_type: 'Section',
process_type_order: 3,
attribute_id: 9,
attribute_label: 'level7',
attribute_order: 2,
attribute_name: 'level7_1' } ],
[ { id: 6,
process_id: 94,
process_type: 'Section',
process_type_order: 4,
attribute_id: 10,
attribute_label: 'level8',
attribute_order: 1,
attribute_name: 'level8_1' } ],
[ { id: 14,
process_id: 94,
process_type: 'Section',
process_type_order: 5,
attribute_id: null,
attribute_label: null,
attribute_order: null,
attribute_name: null } ],
]
【问题讨论】:
-
我们需要在页面列表中使用这个多维数组。
-
然后呢?你似乎没有付出任何努力来解决这个问题。你的尝试在哪里? SO 不是免费的开发服务。
-
嘿,安迪,谢谢你的建议..
标签: javascript arrays node.js