I am creating dynamic variation and this is my JSON output for variation.
[
{
variant: {
name: 'Size',
code: 'size',
type: 'text',
options: [
{value: 'Small'},
{value: 'Medium'},
{value: 'Large'},
{value: 'Extra Large'},
]
}
},
{
variant: {
name: 'Color',
code: 'color',
type: 'text',
options: [
{value: 'Red'},
{value: 'Green'},
{value: 'Blue'},
]
},
}
]
Now i want to group the options value to get the below result from above JSON. But it is totaly not making me send how i'll group it like that.
props.modelValue.forEach(({variant}) => {
variant.options.forEach((value) => {
console.log(value)
});
});
[
{'size':'Small','color':'Red'},
{'size':'Small','color':'Green'},
{'size':'Small','color':'Blue'},
{'size':'Medium','color':'Red'},
{'size':'Medium','color':'Green'},
{'size':'Medium','color':'Blue'},
{'size':'Large','color':'Red'},
{'size':'Large','color':'Green'},
{'size':'Large','color':'Blue'},
{'size':'Extra Large','color':'Red'},
{'size':'Extra Large','color':'Green'},
{'size':'Extra Large','color':'Blue'},
]