【发布时间】:2015-12-11 03:43:29
【问题描述】:
使用 Node,我正在实现一个 ID3 标签解析器,以从 MP3 中获取标题、专辑和艺术家。
现在,我需要取回我得到的信息,并按专辑名称对它们进行分组。
在我的具体用法中,我试图从
这个:
[
{
title: 'Break You',
artist: 'Lamb Of God',
album: 'Ashes Of The Wake'
},
{
title: 'An Extra Nail For Your Coffin',
artist: 'Lamb Of God',
album: 'Ashes Of The Wake'
},
{
title: 'Envy And Doubt',
artist: 'Sever The King',
album: 'Traitor'
},
{
title: 'Self Destruct',
artist: 'Sever The King',
album: 'Traitor'
},
...
]
至此:(伪代码)
[
'Ashes Of The Wake'{
{
title: 'Break You',
artist: 'Lamb Of God'
},
{
title: 'An Extra Nail For Your Coffin',
artist: 'Lamb Of God'
}
}
'Traitor'{
{
title: 'Envy and Doubt',
artist: 'Sever The King'
},
{
title: 'Self Destruct',
artist: 'Sever The King'
}
},
...
]
最好的方法是什么?我对JS比较陌生,所以可能很简单。
【问题讨论】:
-
underscorejs 有 groupBy 如果你想使用它。您想要的输出是无效的 javascript 仅供参考。
-
这是实际数据吗?我不相信'An Extra Nail For Your Coffin'来自那张专辑。 :)
-
@JesseKernaghan 你让我担心我的 ID3 解析器坏了! :) 但是查了一下,这首歌在《Ashes of the Wake》中
标签: javascript json node.js electron