0% found this document useful (0 votes)
5 views

Copy of JSON Web App Code

Uploaded by

kishorsrinivas96
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Copy of JSON Web App Code

Uploaded by

kishorsrinivas96
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

function doGet(e){

// Change Spread Sheet url


var ss = SpreadsheetApp.openByUrl("Your Spread Sheet URL");

// Sheet Name, Chnage Sheet1 to Users in Spread Sheet. Or any other name as you wish
var sheet = ss.getSheetByName("Users");

return getUsers(sheet);

function getUsers(sheet){
var jo = {};
var dataArray = [];

// collecting data from 2nd Row , 1st column to last row and last column
var rows = sheet.getRange(2,1,sheet.getLastRow()-1, sheet.getLastColumn()).getValues();

for(var i = 0, l= rows.length; i<l ; i++){


var dataRow = rows[i];
var record = {};
record['id'] = dataRow[0];
record['name'] = dataRow[1];

dataArray.push(record);

jo.user = dataArray;

var result = JSON.stringify(jo);

return
ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON);

You might also like