BigQueryでクエリ結果をJSONで取得する


やりたいこと

  • BigQueryにて、クエリ結果をJSONで取得する

やりかた

SELECT TO_JSON_STRING(t) FROM (SELECT hoge, fufa FROM sample_table) AS t

SELECT TO_JSON_STRING(t) AS j
FROM (
    SELECT 
        "hoge" AS foo,
        "fuga" AS bar
    UNION ALL 
    SELECT
        "piyo" AS foo,
        "nya" AS bar
) AS t