After scraping an html table I have stored my data in the variable:
var data = ["header1", "header2", "a1", "a2", "b1", "b2", "c1", "c2"];
I want to create a json file in the form:
var json = [
{
"header1":"a1",
"header2":"a2"
},
{
"header1":"b1",
"header2":"b2"
},
{
"header1":"c1",
"header2":"c2"
}
]
I know that I need
var headers={};
and load it with
headers["header1"]
headers["header2"]
I also need
var jsonObj = [];
and push the array headers inside jsonObj:
jsonObj.push(headers);
Is it possible to create it?