0

我正在使用 Scala 的 BigQuery。我尝试了示例 Scala 代码来调用 Google bigQuery API

斯卡拉:

val queryInfo: QueryRequest = 
  new QueryRequest().setQuery(s"SELECT * FROM $PROJECT_ID:$dataSetId.$tableId;")
val queryRequest: Bigquery#Jobs#Query = 
  bigquery.jobs().query(PROJECT_ID, queryInfo)
val queryResponse: QueryResponse = 
  queryRequest.execute()

以上 BQ 回报:

{
  "jobComplete":true,
  "jobReference":{
    "jobId":"job_xxx",
    "projectId":"xxx"
  },
  "kind":"bigquery#queryResponse",
  "rows":[{"f":[{"v":"1"},{"v":"1364206559422"}]}],
  "schema": {
    "fields":[
      {"mode":"NULLABLE","name":"id","type":"STRING"},
      {"mode":"NULLABLE","name":"timestamp","type":"INTEGER"}
    ]
  },
  "totalRows":"1",
  "pageToken":"xxxx"
}

请帮助我以 JSON 格式解析结果上方的值,或更改查询以返回如下格式的结果:

{"id": "1", "timestamp": "1364206559422"}
4

1 回答 1

0

我喜欢提升 json

看看乐透的例子,案例类很简单

于 2013-03-26T11:15:51.527 回答