我试图重新集合一个复杂的对象数组。使用多个复合对象对数组项目进行组合
这里是我的数组:
[
{ scenario: "Treasury", diagnostic: "good results", action: "Manage Financial Recovery"},
{ scenario: "Treasury", diagnostic: "good results", action: "Analyze the impact of your investments"},
{ scenario: "Treasury", diagnostic: "Significant decline", action: "Ensure an adequate"},
{ scenario: "Treasury", diagnostic: "Significant decline", action: "Pilot your cash"},
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your business", action: "Valorize your labels"},
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your business", action: "Analyze the opportunity"}
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your firm", action: "Contacter un prestataire"}
];
我想统一上面这一个数组:
[
{
scenario: "Treasury",
diagnostics: [
{
diagnostic : "good results",
actions: [
"Manage Financial Recovery",
"Analyze the impact of your investments"
]
}
{
diagnostic : "Significant decline",
actions: [
"Ensure an adequate",
"Pilot your cash"
]
}
]
},
{
scenario: "Turnover",
diagnostics: [
{
diagnostic : "Improve trade efficiency of your business",
actions: [
"Valorize your labels",
"Analyze the opportunity"
]
}
{
diagnostic : "Improve trade efficiency of your firm",
actions: [
"Contacter un prestataire"
]
}
]
}
];
所以我试图用JSBin统一我的数组,但我并没有得到预期的结果,那么获得一个没有重复项的数组的最有效方法是什么?
的[什么是最有效的方法来GROUPBY对象的一个JavaScript阵列上?](HTTP可能重复:// stackoverflow.com/questions/14446511/what-is-the-most-efficient-method-to-groupby-on-a-javascript-array-of-objects) –
可能,但我的数组和我的预期结果是更复杂的和回答并没有帮助我解决用户想要统一的其他问题中的问题Ÿ两个键在我的阵列中我有很多重复的键要统一 –
请尝试http://stackoverflow.com/q/36196298/215552。这个问题和问题已经在SO上反复提出。 –