google script - json into google sheet -


i'm new scripting , appreciate help. apologize might simple question.

what have api gives json:

[{"id":"xyz","name":"xy"}, {"id":"zyx","name":"yx"}]

the above continues lets 100 ids.

what want put cells in google spreadsheet.

what have is:

var ss = spreadsheetapp.getactive(); var sh = ss.getactivesheet(); var rr = sh.getrange(3,2,100,5);  var id = "www.xyz.com/api"; var jsondata = urlfetchapp.fetch(id); var jsonstring = jsondata.getcontenttext(); var idsearch = json.parse(jsonstring);  (var = 1; < idsearch.count; i++)   {      var cellid = rr.getcell(i,1);      eventid.setvalue(idsearch.results[i].id);      var cellname = rr.getcell(i,2);      eventname.setvalue(idsearch.results[i].name);   } 

when run script, nothing happens. doesnt return anything.

did make mistake in script? there easier way put json result google sheet? there example can @ learn i'm trying do?

thank much.

i hope simple code might you.

function myfunction() {   var ss = spreadsheetapp.getactivespreadsheet();   var sheets = ss.getsheets();   var sheet = ss.getactivesheet();    var dataset = [     {"id":"xyz","name":"xy"},     {"id":"zyx","name":"yx"}   ];    var rows = [],       data;    (i = 0; < dataset.length; i++) {     data = dataset[i];     rows.push([data.id, data.name]);   }    datarange = sheet.getrange(1, 1, rows.length, 2);   datarange.setvalues(rows);  } 

enter image description here


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -