I want to create an array from a string using pure JS with this structure:
vehicles:[
{
information:{brand: audi, model: a3, year: 2007},
characteristics: {motor: CDI, potency: X}
},
{
information:{brand: bmw, model: x3, year: 2002},
characteristics: {motor: TDI, potency: Y}
}
]
and my strings are
vehicles[0].information.brand = audi;
vehicles[0].information.model = a3;
vehicles[0].information.year = 2007;
vehicles[0].characteristics.motor = CDI;
vehicles[0].characteristics.potency = X;
vehicles[1].information.brand = bmw;
vehicles[1].information.model = x3;
vehicles[2].information.year = 2002;
vehicles[2].characteristics.motor = TDI;
vehicles[2].characteristics.potency = Y;
I was able to create the object part, but I'm having struggle with array indexes and how to create this parent-child relation.