【发布时间】:2018-12-25 17:04:33
【问题描述】:
我正在尝试使用内置数据流模板从 PUBSUB 在 Big Query 中加载以下数据:
{
"current_speed": "19.09",
"_east": "-87.654561",
"_last_updt": "2018-07-17 15:50:54.0",
"_region_id": "1",
"_north": "42.026444",
"_south": "41.997946",
"region": "Rogers Park - West Ridge",
"_west": "-87.709645",
"_description": "North of Devon. Kedzie to Lake Shore"
}
但我不断收到此错误:
“读取数据时出错,错误信息:解析JSON失败: 字符串意外结束;字符串意外结束;预期的密钥”
我实际上需要加载更大的数据集,如下所示:
[{
"current_speed": "19.09",
"_east": "-87.654561",
"_last_updt": "2018-07-17 15:50:54.0",
"_region_id": "1",
"_north": "42.026444",
"_south": "41.997946",
"region": "Rogers Park - West Ridge",
"_west": "-87.709645",
"_description": "North of Devon. Kedzie to Lake Shore"
}, {
"current_speed": "25.23",
"_east": "-87.747456",
"_last_updt": "2018-07-17 15:50:54.0",
"_region_id": "2",
"_north": "42.0190998",
"_south": "41.960669",
"region": "Far North West",
"_west": "-87.84621",
"_description": "North of Montrose. East River to Cicero"
}
]
但是我得到了这个错误:
读取数据时出错,错误消息:无法解析 JSON:否 新数组启动时找到的对象。;开始数组返回假; 解析器在字符串结束前终止
我在这里做错了什么?
【问题讨论】:
-
不清楚是谁/什么在发送该错误消息 - 以及您如何执行它。你能添加更多的实现细节吗?
-
嗨@FelipeHoffa 感谢您的回复。我正在尝试使用 BQ UI 上传我的 JSON 以在实现管道之前对其进行测试。我实际上取得了一些进展。我发现 BQ 喜欢这个 "{ "current_speed" : "19.77", "_east" : "-87.654561", "_last_updt" : "2018-07-17 15:31:30.0", "_region_id" : "1 ","_north":"42.026444","_south":"41.997946","region":"罗杰斯公园 - 西岭","_west":"-87.709645","_description":"德文郡北部。 Kedzie 到 Lake Shore" }" 即元素之间没有换行符。但仍然不知道如何处理数组。
-
再次澄清:我现在可以插入单个 json 对象,但不能插入数组。从我最初的对象中,我必须删除所有换行符并将整个内容压缩在一行中。我认为这很奇怪,但它至少可以工作。
-
请针对新问题发布新问题 - 如果您不使用 Pub/Sub 或 Dataflow 直接导入 BigQuery,请注明。
标签: json google-bigquery