Javascript'无法将数组转换为Object [] []

时间:2017-11-28 11:03:26

标签: javascript json

下面代码的最后一行返回主题中的错误消息。我尝试了很多变化但仍然相同。数据分为5列和100行。我复制粘贴在线json转换器中的数据,它很好。

  var url = 'https://api.gdax.com/products/ETH-EUR/trades';
  var response3 = UrlFetchApp.fetch(url);

  // convert to string
  var rawtrades = String(response3);
  //var rawtrades = String(rawstring.substring(rawstring.indexOf("[")+1, rawstring.length-1));

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var first = ss.getSheetByName("trades");
  first.activate();

  var cell = first.getRange("B2");
  cell.setValue(rawtrades);    


  //splitting each block of rawtrades into an array
  var array4 = JSON.parse(rawtrades);

  //copy each element of array3 in 5 columns and rows
  rgMyRange = first.getRange("B10:F109");
  rgMyRange.setValues(array4);

0 个答案:

没有答案