'Converting sql results to json in BigQuery

I have two tables

Table_A: |person_id|date_cons| |:----|:----:| |001|2022-01-01|

Table_B: |person_id|date_cons| |:----|:----:| |001|2022-01-01|

Using bigquery editor, when running the query I would like my result to be a json:

{
   "table_a":[
      {
         "id_person":"001",
         "date_cons":"2022-01-01"
      }
   ],
   "table_b":[
      {
         "id_person":"001",
         "date_cons":"2022-01-01"
      }
   ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source