Hello everyone, I'm currently working on implementing handlebars templating and to do so I need to generate a JSON from array values
{"path":"Avions", "fileName":"AvionsEdit.vue"},{"path":"Avions",
"fileName":"AvionsShow.vue"}etc...
While I can create a JSON like the one shown in the code snippet above, I would prefer the format below:
{"path":["Avions","Avions"],"fileName":
["AvionsEdit.vue","AvionsShow.vue"]}
var foo = {"path" : [], "fileName": []};
for(i = 0; i < list.length; i++) {
foo.path.push(list[i]);
foo.fileName.push(list[i]+extList[i]+".vue");
}
console.log(JSON.stringify(foo));
Here is the list I'm working with:
['Avions',
'Avions']
And here is the extList corresponding to each item in the list:
['Edit',
'Show']