例如,我已经尝试过这个,但它不起作用。我必须创建一个在一个字段中包含数组数组的模式,但我无法做到这一点。
{
"name": "SelfHealingStarter",
"namespace": "SCP.Kafka.AvroSchemas",
"doc": "Message with all the necessary information to run Self Healing process.",
"type": "record",
"fields": [
{
"name": "FiveMinutesAgoMeasurement",
"type": "record",
"doc": "Field with all five minutes ago measurement.",
"fields": [
{
"name": "equipments",
"doc": "List with all equipments measurement.",
"type": {
"type": "array",
"items": {
"type": {
"type": "array",
"items": "string"
},
"default": []
}
},
"default": []
}
]
}
]
}
"type"
和 "items"
一起出现在一个对象内,例如
"type": { "type": "array", "items": { ... } }
重复进入最里面的对象。
举一个更简单的例子 - 这是数组数组的 IDL 定义
protocol Example {
record Foo {
array<array<string>> data = [];
}
}
AVSC 来自
java -jar ~/Downloads/avro-tools-1.8.2.jar idl2schemata example.idl
{
"type" : "record",
"name" : "Foo",
"fields" : [ {
"name" : "data",
"type" : {
"type" : "array",
"items" : {
"type" : "array",
"items" : "string"
}
},
"default" : [ ]
} ]
}