【发布时间】:2021-03-24 15:22:28
【问题描述】:
我一直在尝试将 JSON 手动上传到 BigQuery,但收到以下错误消息。
Error while reading data, error message: JSON parsing error in row starting at position 0: Repeated field must be imported as a JSON array. Field: custom_fields.value.
我已经将文件转换为换行符分隔的 JSON,所以这不是问题。 从错误中查看 custom_field.value 时,我得到以下信息:
$ cat convert2working.json | jq .custom_fields[].value
0
"Basics of information security\n"
"2021"
问题似乎是custom_fields.value的数据类型不同。
如何“同质化”这些数据类型?还是您有其他解决方案。我宁愿留在 javascript 中
这是我的 JSON 代码的缩短版本:
{
"id": "example",
"custom_fields": [
{
"id": "example",
"name": "Interval",
"type": "drop_down",
"type_config": {
"default": 0,
"placeholder": null,
"options": [
{
"id": "example",
"name": "yearly",
"color": null,
"orderindex": 0
}
]
},
"date_created": "1611228211303",
"hide_from_guests": false,
"value": 0,
"required": false
},
{
"id": "example",
"name": "Description",
"type": "text",
"type_config": {},
"date_created": "1611228263444",
"hide_from_guests": false,
"value": "Basics of information security\n",
"required": false
},
{
"id": "example",
"name": "Year",
"type": "number",
"type_config": {},
"date_created": "1611228275285",
"hide_from_guests": false,
"value": "2021",
"required": false
}
]
}
【问题讨论】:
-
您应该与他人分享您当前的 javascript 代码,以便他们更好地了解您的问题并帮助您解决问题。
-
我还没有 javascript 代码,因为我想看看是否可以先手动将其上传到 BigQuery。
-
我只是您帖子的审阅者,从未听说过 BigQuery。但我对返回消息的理解是,您将 BigQuery 中的字段值定义为重复字段,因此,google 期望您在
value中的数据是一个数组而不是字符串。所以我想说:它看起来像是大查询中的数据结构定义中的一个问题。我认为您可以通过更改其中的字段配置或将value包装在[]之间来解决您的问题。"value": ["2021"],
标签: javascript json google-bigquery