Last active
November 23, 2020 19:52
-
-
Save jonobr1/602e9e3283d628ff4bec4508043daa30 to your computer and use it in GitHub Desktop.
Google AppScript for serving your Sheet as a publicly accessible JSON file. Following these steps in your Google Sheets: https://levelup.gitconnected.com/turn-your-google-sheet-into-a-web-application-f766f1ff8b98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var range = sheet.getDataRange(); | |
var values = range.getValues(); | |
var result = []; | |
for (var i = 0; i < values.length; i++) { | |
var row = []; | |
for (var j = 0; j < values[i].length; j++) { | |
if (values[i][j]) { | |
row.push(values[i][j]); | |
} else { | |
row.push(''); | |
} | |
} | |
result.push(row); | |
} | |
return ContentService.createTextOutput(JSON.stringify(result)) | |
.setMimeType(ContentService.MimeType.JSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment