title: Google Sheet App Scripts : How to parse JSONs in Sheet A column A to Sheet B?
body: <p>I have a google spreadsheet with Sheet A having <a href="https://i.stack.imgur.com/XMgjY.png" rel="nofollow noreferrer">JSONs in column A</a> and I'd like to populate Sheet B with the data with <a href="https://i.stack.imgur.com/qArBI.png1" rel="nofollow noreferrer">respective rows and columns.</a> However I'm not entirely sure how to start. I'm a bit confused about the whole process. First declaring sheet. I've seen people using the following:</p>
  <pre><code>function parseJSON()
  {
      var ss = SpreadsheetApp.getActiveSpreadsheet();  // Gets the Active Spreadsheet
      var sheet = ss.getSheets()[0]; // Gets the first sheet
      var parsed = JSON.parse(json);
  
      sheet.appendRow([json.items[i].id, json.items[i].name, json.items[i].url]);
  }
  </code></pre>
  <p>but I have in 1 active spreadsheet from sheet A to sheet B. So would i need to declare a second sheet (my sheet B)?</p>
  <pre><code>var ss = SpreadsheetApp.getActiveSpreadsheet();  // Gets the Active Spreadsheet
  var sheet1 = ss.getSheets()[0]; // Gets the first sheet
  var sheet2 = ss.getSheets()[1]; // Gets the first sheet
  
  sheet2.appendRow([json.items[i].id, json.items[i].name, json.items[i].url]);
  </code></pre>
  <p>or i dont need those declarations and i just</p>
  <pre><code>function parseJSON(parsed)
  {
  
      return [parsed.items[i].id, parsed.items[i].name, parsed.items[i].url]
  }
  </code></pre>
  <p>so in Sheet B A1 i just put =parseJSON(SheetB!A) or something equivalent which im still unsure.</p>
  <p>Also how do i declare what are headers and the values according to the JSON? Should the headers be declared?</p>
  <pre><code>const headers = [&quot;dish_name&quot;,&quot;dish_price&quot;,&quot;dish_quantity&quot;];
  </code></pre>
  <p>or is it possible to get the header from the JSON? How about the corresponding values? Does Apps Ssripts accept foreach loop?</p>
  <p><strong>For additional context (for selected answer that helped)</strong></p>
  <p>JSON Obj - <code>{&quot;55&quot;:{&quot;dish_name&quot;:&quot;(Ala Carte) Claypot Soup with Rice and Char Kuih&quot;,&quot;dish_price&quot;:17,&quot;dish_quantity&quot;:1,&quot;dish_size_name&quot;:&quot;default&quot;,&quot;dish_size_price&quot;:0,&quot;dish_addon_name&quot;:&quot;default&quot;,&quot;dish_addon_price&quot;:0,&quot;dish_variation_name&quot;:&quot;default&quot;,&quot;dish_variation_price&quot;:0}}</code></p>
  <p>the selected answer was able to split it up in key value pairs. so constant keys were headers, rows were the corresponding values.</p>