I am trying to import a json file using Fetch() to populate multiple Google sheets I have been trying for a few hours but I do not know enough to do this
The json is dynamic so its data is always changing but its structure remains the same my json looks like
{
"connections": [
{
"Id": 131527,
"From": 49647,
"To": 49644,
"Name From": "Horus Max",
"Name To": "Bob allison",
"Initial Date": "9/21/2020 15:20",
"Last Date": "9/21/2020 15:20",
"Type": "",
"Weight": 0,
"Checkbox ZZZ": "",
"Text Area": "",
"Radio AAA": "value one AAA",
"Select bbb": "value one sss"
},
{
},
],
"elements": [
{
"Id": 49645,
"Type": "Person",
"Label": "Sally Yager",
"First Name": "Sally",
"Last Name": "Yager",
"Description": "",
"Segment": "555",
"Image": null,
"Project Name": "test222",
"Initial Date": "09/29/2020 17:44",
"Last Date": "09/29/2020 17:47",
"Issues Checkbox": [
"Option 1",
"Option 6"
],
"IssuesRadio": "Option 3",
"Notes": "222"
},
{
}
],
"name": "My project name"
}
I need the elements data passed into a sheet called elements and the Connections data parsed into a sheet called Connections
What I get
I have
//=fetchdata("https://sum-app.net/projects/14312620200623668/download_data/kumu_json")
async function fetchdata(url) {
var response = await UrlFetchApp.fetch(url);
var responseText = await response.getContentText();
var responseJson = JSON.parse(responseText);
// Return something to display in the Google Sheet.
var rows = [Object.keys(responseJson)]; // Retrieve headers.
var temp = [];
for (var i = 0; i < rows[0].length; i++) {
temp.push(responseJson[rows[0][i]]); // Retrieve values.
}
rows.push(temp);
return temp
}
Here is a Google sheet with what I get and the desired outcome https://docs.google.com/spreadsheets/d/14vxiueXsUzFtkw22RHA7qVFE--PFVSwfj4zJIU7I3nk/edit?usp=sharing
Thanks