gpt4 book ai didi

java - JSON 到 Avro 转换异常 - 预期启动联合。已获取 VALUE_STRING

转载 作者:行者123 更新时间:2023-12-02 09:02:39 35 4
gpt4 key购买 nike

我有以下 avsc(Avro 架构):

{
"type": "record",
"name": "DataEventId",
"fields": [
{
"name": "redeliveredDataEventIndices",
"type": { "type": "array", "items": "int" },
"doc" : "Data event indices",
"default": []
},
],
"namespace": "com.xxx.xxx.xxx"
}

当我尝试使用此架构将 json 转换为 avro 时,出现以下错误:

org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_STRING

我的输入数据:

{"redeliveredDataEventIndices":"[]"}

我知道这是 How to fix Expected start-union. Got VALUE_NUMBER_INT when converting JSON to Avro on the command line? 的重复项但如何为类型数组提供输入(在本例中,redeliveredDataEventIndices 是 int 类型的数组)

最佳答案

您的输入数据将数组用引号括起来,因此将其视为字符串。

试试这个:

{"redeliveredDataEventIndices":[]}

关于java - JSON 到 Avro 转换异常 - 预期启动联合。已获取 VALUE_STRING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60053309/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com