Task: Converting Nested Objects in an Array to Dot Notation String Using JavaScript
Here is a sample data structure that needs to be converted:
[
{
property: 'name',
children: [],
message: 'name should not be empty',
},
{
property: 'priceForm',
children: [
{
property: 'priceCurrency',
children: [],
message: 'priceCurrency should not be empty',
},
],
},
{
property: 'priceForm',
children: [
{
property: 'rolePrices',
children: [
{
property: '0',
children: [
{
property: 'markupType',
children: [],
message: 'markupType should not be empty',
},
],
},
],
},
],
},
]
Desired Output:
{
'name': 'name should not be empty',
'priceForm.priceCurrency': 'priceCurrency should not be empty',
'priceForm.rolePrices.0.markupType': 'markupType should not be empty',
}