テンプレートに渡すことができるように再配置したい次のオブジェクトがあります。次の形式から変換するためのヘルプが必要です
var nature = [
{
"type": "fruit",
"name": "apple",
"color": "red",
},
{
"type": "vegetable",
"name": "carrot",
"color": "orange",
},
{
"type": "fruit",
"name": "grape",
"color": "green",
},
{
"type": "vegetable",
"name": "tamato",
"color": "red",
},
];
このフォーマットに
var nature = [{
"fruit": [
{
"type": "fruit",
"name": "apple",
"color": "red"
},
{
"type": "fruit",
"name": "grape",
"color": "green"
}
],
"vegetable": [
{
"type": "vegetable",
"name": "carrot",
"color": "orange"
},
{
"type": "vegetable",
"name": "tomato",
"color": "red"
}
]
}];
それを達成するための最速の方法を探しています。投稿を見ていただきありがとうございます。助けに感謝します。