json 2D array example

Example 1: convert json to 2d array

function jsonArrayTo2D(arrayOfObjects){
  let header = [],
      AoA = [];
  arrayOfObjects.forEach(obj => {
    Object.keys(obj).forEach(key => header.includes(key) || header.push(key))
    let thisRow = new Array(header.length);
    header.forEach((col, i) => thisRow[i] = obj[col] || '')
    AoA.push(thisRow);
  })
  AoA.unshift(header);
  return AoA;
}

Example 2: json 2d array c#

{     "range": "Sheet1!A1:D4",     "majorDimension": "ROWS",     "values": [         ["key", "en-gb", "en-us", "nl-nl"],         ["MAIN_MENU", "main menu", "main menu", "hoofdmenu"],         ["SHOP", "store", "shop", "winkel"],         ["CHARACTER_SELECTION", "character selection", "character selection", "Karakter keuze"]     ] }