- Converting Google Sheets cell values to an object array with heading keys using Google Apps Script
- Google sheet to json object
function myFunction() {
const sheetName = "Sheet1";
const [headers, ...rows] = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName(sheetName)
.getDataRange()
.getValues();
const res = rows.map((r) =>
headers.reduce((o, h, j) => Object.assign(o, { [h]: r[j] }), {})
);
console.log(res);
}