underscore groupBy 迭代结果
underscore groupBy iterating the result
我有一个对象数组,我使用 groupBy 获得了以下结果。
{ 'Cloud Revenue':
[ { sessionName: 'Business Growth',
channelName: 'Cloud Revenue',
channelId: '19:8f128db81595434cb91359e5ebb5a58f@thread.tacv2',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '08:00:00.0000000',
endTime: '08:30:00.0000000' },
{ sessionName: 'Increase Market Value',
channelName: 'Cloud Revenue',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '06:30:00.0000000',
endTime: '07:00:00.0000000' } ],
General:
[ { sessionName: 'Value Proposition',
channelName: 'General',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '07:30:00.0000000',
endTime: '08:00:00.0000000' } ] }
现在,我需要按键枚举实体。例如,在上述情况下,我需要提取顶级 属性 名称(Cloud Revenue 和 General)并将其分配给字符串变量。我尝试使用 foreach、_.map 和 _.each,没有什么能为我提供顶级 属性 字符串。我怎样才能做到这一点?
var obj= { 'Cloud Revenue':
[ { sessionName: 'Business Growth',
channelName: 'Cloud Revenue',
channelId: '19:8f128db81595434cb91359e5ebb5a58f@thread.tacv2',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '08:00:00.0000000',
endTime: '08:30:00.0000000' },
{ sessionName: 'Increase Market Value',
channelName: 'Cloud Revenue',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '06:30:00.0000000',
endTime: '07:00:00.0000000' } ],
General:
[ { sessionName: 'Value Proposition',
channelName: 'General',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '07:30:00.0000000',
endTime: '08:00:00.0000000' } ] }
for(keys in obj){
console.log(keys);
}
我有一个对象数组,我使用 groupBy 获得了以下结果。
{ 'Cloud Revenue':
[ { sessionName: 'Business Growth',
channelName: 'Cloud Revenue',
channelId: '19:8f128db81595434cb91359e5ebb5a58f@thread.tacv2',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '08:00:00.0000000',
endTime: '08:30:00.0000000' },
{ sessionName: 'Increase Market Value',
channelName: 'Cloud Revenue',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '06:30:00.0000000',
endTime: '07:00:00.0000000' } ],
General:
[ { sessionName: 'Value Proposition',
channelName: 'General',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '07:30:00.0000000',
endTime: '08:00:00.0000000' } ] }
现在,我需要按键枚举实体。例如,在上述情况下,我需要提取顶级 属性 名称(Cloud Revenue 和 General)并将其分配给字符串变量。我尝试使用 foreach、_.map 和 _.each,没有什么能为我提供顶级 属性 字符串。我怎样才能做到这一点?
var obj= { 'Cloud Revenue':
[ { sessionName: 'Business Growth',
channelName: 'Cloud Revenue',
channelId: '19:8f128db81595434cb91359e5ebb5a58f@thread.tacv2',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '08:00:00.0000000',
endTime: '08:30:00.0000000' },
{ sessionName: 'Increase Market Value',
channelName: 'Cloud Revenue',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '06:30:00.0000000',
endTime: '07:00:00.0000000' } ],
General:
[ { sessionName: 'Value Proposition',
channelName: 'General',
startDate: '2020-04-12',
endDate: '2020-04-12',
startTime: '07:30:00.0000000',
endTime: '08:00:00.0000000' } ] }
for(keys in obj){
console.log(keys);
}