I’m looking to turn text like this into JSON:
Company Team
Facebook Marketing
Google Engineering
Microsoft Product
When I log the JSON.stringify returns "
instead of "
. Why does that happen? What can I change to prevent this?
let pre = document.querySelector('pre').innerHTML;
var cells = pre.split('n').map(function (el) { return el.split(/s+/); });
var headings = cells.shift();
var obj = cells.map(function (el) {
var obj = {};
for (var i = 0, l = el.length; i < l; i++) {
obj[headings[i]] = isNaN(Number(el[i])) ? el[i] : +el[i];
}
return obj;
});
var json = JSON.stringify(obj,null,5);
console.log(json)