user2148971 user2148971 - 25 days ago 11
JSON Question

NODEJS parse cell value get from google sheets

I get value from cell range from google sheets using REST api, this is my response from google sheets

{
"range": "RECORD!A2:J2",
"majorDimension": "ROWS",
"values": [
[
"07/11/2016",
"21:20:10",
"3",
"MAIN",
"Nam",
"1",
"xxxxxxxxxxx",
"xxxxxxxxxxx",
"xxxxxxxxxxx",
"xxxxxxxxxxx"
]
]
}


I try to use JSON.parse() method. Here my code

var data = JSON.parse(response); //reponse store presponse from google sheets
var data_values = resposne.values[0];


How I get data from values[0]? like:

var DAY = values[0][0];
var TIME = values[0][1];
var NO = values[0][2];
var OBJECT = values[0][3];
var NAME = values[0][4];
.........

Sam Sam
Answer
for(var i=0;i<response.values.length;i++){
  for(var j=0;j<response.values[i].length;i++){
          var DAY = values[i][j];
          var TIME = values[i][j];
          var NO = values[i][j];
          var OBJECT = values[i][j];
          var NAME = values[i][j];
  }
}
Comments