Per the documentation in ImportJSON
, it returns a two-dimensional array (which actually means an array of arrays, since JS doesn’t have two-dimensional arrays). This is probably meant to mimic the structure of spreadsheet data (rows of columns). Since each of the items in the array you’re concat
ing is itself an array, you’ll get that nested structure.
You’ll need to flatten. reduce
can help with that:
const importedJSON = ImportJSON(`http://api.etf2l.org/competition/${competitionId}/matches/${i}.json`, '/matches/clan1/id', 'noHeaders');
clan1Id = importedJSON.reduce((result, row) => result.concat(row), clan1Id);
…or simply this if you’re assuming ImportJSON
is returning a single row:
const url = `http://api.etf2l.org/competition/${competitionId}/matches/${i}.json`;
clan1Id = clan1Id.concat(ImportJSON(url, '/matches/clan1/id', 'noHeaders')[0])
solved Trying to create an array and instead creating an array within an array