title: Generating Nested JSON for bigquery
body: <p>I have created a nested table in Bigquery.  The input needs to be JSON.  I need the input to be following example:</p>
  
  <p>{"store_nbr":"1234","sls_dt":"2014-01-01 00:00:00", "Items":[{"sku":"3456", "sls_amt":"9.99", "discounts":[{"disc_nbr":"1","disc_amt":"0.99"},{"disc_nbr":"2","disc_amt":"1.00"}]]</p>
  
  <p>I have the flattened tables in big query. I have read nest can help in pivoting for repeated json.  I have seen an example in another thread which is very nice.</p>
  
  <p><a href="https://stackoverflow.com/questions/35781272/nest-multiple-repeated-fields-in-bigquery">Nest multiple repeated fields in BigQuery</a></p>
  
  <p>But that does only for one level nesting.  I need to do two levels "Items" -> "Discounts".  Any suggestions are appreciated.  </p>