这是我的JSON示例:
{"ID":2,"name":"Donatello","lastname":"Di Niccoló","age":23,"hobbies":["reading","dancing",{"sports":["rafting","baseball"]}],"address":{"street":"Tepito", "number":"77", "districts":"Benito Juárez", "country": "CDMX"}}
这是我的AVRO SCHEMA
{"type":"record","name":"myrecord","fields":[
{"name":"ID","type":"int"},
{"name":"name", "type": "string"},
{"name":"lastname", "type": "string"},
{"name":"age", "type": "int"},
{"name":"hobbies","type": {
"type": "array",
"items": {
"type": "array", "items": "string",
"type":"record","name":"myhobbies",
"fields":[
{"name":"sports","type":{"type": "array", "items": "string"}}
]
} }
},
{"name":"address","type":{"type":"record","name":"myaddress",
"fields":[
{"name":"street","type":"string"},
{"name":"number","type":"string"},
{"name":"districts","type":"string"},
{"name":"country","type":"string"}
]
}
}
]}
我需要avro格式couse我想开始制作人员whit kafka但是当我开始它时,当我输入previos记录时出错。 Couse avro架构与记录不匹配。如何使它们匹配
Yeah Nitin Tripathi
{"type":"record","name":"myrecord","fields":[
{"name":"ID","type":"int"},
{"name":"name", "type": "string"},
{"name":"lastname", "type": "string"},
{"name":"age", "type": "int"},
{"name":"hobbies","type": {
"type": "array",
"items": {
"type":"record","name":"myhobbies",
"fields":[
{"name":"sports","type":{"type": "array", "items": "string"}}
]
} }
},
{"name":"address","type":{"type":"record","name":"myaddress",
"fields":[
{"name":"street","type":"string"},
{"name":"number","type":"string"},
{"name":"districts","type":"string"},
{"name":"country","type":"string"}
]
}
}
]}
我试过了,但它不起作用:(
答案 0 :(得分:0)
数组使用类型名称"数组"并且支持单个属性,但是,爱好的模式混合了字符串和myhobbies类型