Is there an easy way to convert rows in BigQuery to JSON?
This is now possible using TO_JSON_STRING
, which can also help when you want to pass a row from your table to a JavaScript UDF.
#standardSQL
WITH MyTable AS (
SELECT 1 AS x, 'foo' AS y, true AS z UNION ALL
SELECT 2, 'bar', false
)
SELECT TO_JSON_STRING(t) AS json
FROM MyTable AS t;