java - JSON to Avro conversion exception - Expected start-union. Got VALUE_STRING
问题描述
I have the following avsc (Avro schema) :
{
"type": "record",
"name": "DataEventId",
"fields": [
{
"name": "redeliveredDataEventIndices",
"type": { "type": "array", "items": "int" },
"doc" : "Data event indices",
"default": []
},
],
"namespace": "com.xxx.xxx.xxx"
}
When i try to convert json to avro with this Schema i get the following error :
org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_STRING
My input data :
{"redeliveredDataEventIndices":"[]"}
I know this is a duplicate of How to fix Expected start-union. Got VALUE_NUMBER_INT when converting JSON to Avro on the command line? but how to give input for the type array (redeliveredDataEventIndices is array of type int in this case)
解决方案
您的输入数据将数组括在引号中,因此将其视为字符串。
试试这个:
{"redeliveredDataEventIndices":[]}
推荐阅读
- python - 我如何做到这一点,当我打印 Python 列表时,当我打印列表时,每个项目都没有单引号和括号?
- visual-studio-code - 如何配置 svelte 格式化程序以尊重 HTML 中的换行符?
- javascript - 如何从 Chrome 控制台单击时调用 html 函数?
- c - 如何在C中读取和扫描文件的结构记录
- javascript - 如何动态显示消息 react-router-dom
- javascript - Nightwatch JS 中的异步命令执行
- r - 有没有办法创建一个循环来查找数据集中的特定方法?
- python - 烧瓶如何在扩展模板中获取变量
- python - 代码没有读取 Elif 或 Else 语句
- javascript - 静态包含 HTML 代码而不是在实时环境中的方法?