[ad_1]
I have a *.json file (not URL or something else, only file) that I want to import into Google Sheet. Usually, I just copy the content of the file to the first column in table and then reads that column into one variable, which I then use in JSON.parse to import data which i need.
How can I immediately load this file into "jsonData" variable? Or some another ways to import *.json file to Google Sheet.
function whichIUse()
var active_sheet = SpreadsheetApp.getActiveSheet();
var last_row = active_sheet.getLastRow();
var jsonData = "";
for (var i=0; i <= last_row; i++)
jsonData = jsonData + active_sheet.getRange(1,1).offset(i,0).getValue();
var object = JSON.parse(jsonData);
for (var i=0;i<=object.SomeArray.length;i++)
active_sheet.getRange(i+2,5).setValue(object.SomeArray[i]);
for (var i=0;i<=object.AnotherArray.length;i++)
active_sheet.getRange(i+2,6).setValue(object.AnotherArray[i]);
active_sheet.getRange(2,7).setValue(object.data1);
active_sheet.getRange(2,8).setValue(object.data2);
[ad_2]
لینک منبع