【发布时间】:2020-10-19 15:42:19
【问题描述】:
我有一个带有数组字段的 AVRO 模式。该数组字段的项目是另一个 AVRO 模式的对象。下面是我现在的代码。
{
"name": "bars",
"type": ["null", {
"type": "array",
"items": "com.example.Bar"
}],
"default": null
}
这段代码是“bars”的字段定义,它是一个包含“com.example.Bar”对象的数组。
我现在将默认值设置为“null”,但是我想明确地将默认值设置为 3 个 Bar 对象的数组。
想象一下我的 Bar 有以下字段定义
{
"name": "name",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "number",
"type": [
"null",
"int"
],
"default": null
}
我想将“bars”默认设置为
{
"name": "bars",
"type": ["null", {
"type": "array",
"items": "com.example.Bar"
}],
"default": [{"name": "bar1", "number":1}, {"name": "bar2", "number":2}, {"name": "bar3", "number":3}]
}
但是这段代码不起作用。我应该如何设置对象的默认值?
【问题讨论】:
标签: avro