如何在avro模式中创建包含字符串数组的对象?

时间:2019-01-08 14:27:11

标签: java arrays maven avro

为带有字符串数组的对象创建avro模式的正确方法是什么?

我正在尝试根据官方文档创建具有字符串数组的对象的avro模式?但我出错了。

https://avro.apache.org/docs/1.8.1/spec.html

[错误]无法在项目电子邮件上执行目标org.apache.avro:avro-maven-plugin:1.8.2:schema(默认):目标org.apache.avro:avro-maven-plugin的执行默认值: 1.8.2:模式失败:“数组”不是定义的名称。 “参数”字段的类型必须是定义的名称或{“ type”:...}表达式。 -> [帮助1]

为什么我的架构不正确?

[
  {
    "type": "record",
    "namespace": "com.example",
    "name": "Topic",
    "fields": [
         { "name": "subject", "type": "string" },
         { "name": "parameters", "type": "array", "items": "string" }
    ]    
  }

]

1 个答案:

答案 0 :(得分:2)

这应该可行:

{ 
  "name":"parameters",  
  "type": { 
      "type": "array",
      "items": "string"
   } 
}