Good day. Tell me how to upload to Google Table the data received from the site in JSON format. Below is the code, but I get an error at the output. Cannot convert Array to Object [] [] . In Debug mode, you can see that the code is working, and the error occurs in the last line resultRange.setValues ​​(results);

function processXMRAPI() { var ss = SpreadsheetApp.openById('1v2NmYXtURFR3cnrhmuzrcFX48YQTLGRO8Nq4dkL4l1w'); var APIPullSheet = ss.getSheetByName ("APIPull"); APIPullSheet.getRange('A1:M300').clearContent(); var url = "https://bittrex.com/api/v1.1/public/getmarketsummaries"; var responseAPI = UrlFetchApp.fetch(url); var parcedData = JSON.parse(responseAPI.getContentText()); var results = [[]]; //results.push(['MarketName', 'High', 'Low', 'Volume', 'Last', 'BaseVolume', 'TimeStamp', 'Bid', 'Ask', 'OpenBuyOrders', 'OpenSellOrders', 'PrevDay', 'Created']); for(var i in parcedData.result) { results.push(parcedData.result[i]); } resultRange = APIPullSheet.getRange(1, 1, results.length, 13); resultRange.setValues(results); } 

Tell me, please, what is the error? This is a debugging mode, the stop is in the loop on the line results.push (parcedData.result [i]);

  • Give an example of what you get in parcedData.result - Grundy
  • Added a debugger screen to the question. - Igor Perminov
  • What kind of debugger? - Grundy
  • everything seems to understand what the problem is, now you have the results form: [[], {},{},{}] , but it should look like: [[...],[...],[...]] - Grundy
  • And how to be in this case, I can not fix the JSON message. - Igor Perminov

1 answer 1

The problem with the error was that the result array was not brought to the correct form.

It looked like this [[], {},{},{}] , but it should be: [[...],[...],[...]]

After replacement

 results.push(parcedData.result[i]); 

on

 results[0].push(parcedData.result[i]); 

the error disappeared.