Creating a web app to return JSON

Now, we will see how to return JSON string instead of HTML content. In the Data Sheet, add another column named DOB as shown here:

Creating a web app to return JSON

Create the doGet function as shown here:

function doGet(){ /* * This spreadsheet may not be active while this function * executes, so you cannot get access to active spreadsheet, * use open by id. * */ var ss = SpreadsheetApp .openById("Replace with this spreadsheet id"); var SheetData = ss.getSheetByName("Data"); var data = SheetData.getDataRange().getValues(); // Remove header data.shift(); var date = new Date(); var currYear = date.getFullYear(); var output = {}; data.forEach(function(row){ ...

Get Learning Google Apps Script now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.