I have this script in google script spreadsheet:
function doGet() {
var response = [];
var ss = SpreadsheetApp.getActive();
var thisSheet = ss.getSheetByName('product');
var lastRow = thisSheet.getLastRow();
var allValues = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
var objectResponse = {};
for(var i = 2; i < lastRow ; ++i){
objectResponse.title = allValues[i][1];
objectResponse.url = allValues[i][8];
response.push(objectResponse);
};
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
}
I make this loop to create an array of objects like this
[
{ title: 'first_title_on2column' , URL: 'first_url_on9column'},
{ title: 'second_title_on2column' , URL: 'second_url_on9column'},
...
//until ends <lastRow>
]
but the results is the same on each object. Same 'title' and 'URL'.