function doGet(e){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var json = createJSON(sheetToJsonObj(sheet))
return json
}
function sheetToJsonObj(sheet) {
var sheetVals = sheet.getDataRange().getValues();
var colTitle = sheetVals.shift()
var jsonObj = []
sheetVals.forEach(function(row){
var newRecord = {}
row.forEach(function(el,idx){
newRecord[colTitle[idx]] = el
})
jsonObj.push(newRecord)
})
return jsonObj
}
function createJSON(data){
var jsonString = JSON.stringify(data)
var mimeType = ContentService.MimeType.JSON
var json = ContentService.createTextOutput(jsonString).setMimeType(mimeType)
return json
}