I am reading a local csv file with ajax query , and then loading read values into an array.
This is how the string value looks like in the csv file :
"Tiger","Architect","800","DRP","5421","VFX"
after loading this string into the array , the array looks like this :
0: (6) ["Tiger", "Architect", "800", "DRP", "5421", "VFX"]
now I am trying to convert this above mentioned sting into a json object to look like this :
{
"data": [
{
"0": "Tiger",
"1": "Architect",
"2": "800",
"3": "DRP",
"4": "5421",
"5": "VFX"
}]
}
by having all the values inside one object data
I tried this :
var arrayToString = JSON.stringify(Object.assign({}, data1));
var stringToJsonObject = JSON.parse (arrayToString) ;
it converts the array to json, but with length 6 where as I need the length to be 1
any way to do this ?