Problem
I want to convert a normal Json file like below to an avro schema to make it work in apache kafka with the confluent schema registry.
Example
Input (Json)
[
{
"name": "Robin Hood",
"department": "",
"manager": "",
"salary": 200
},
{
"name": "Arsene Wenger",
"department": "Bar",
"manager": "Friar Tuck",
"salary": 50
},
{
"name": "Friar Tuck",
"department": "Foo",
"manager": "Robin Hood",
"salary": 100
},
{
"name": "Little John",
"department": "Foo",
"manager": "Robin Hood",
"salary": 100
},
{
"name": "Sam Allardyce",
"department": "",
"manager": "",
"salary": 250
},
{
"name": "Dimi Berbatov",
"department": "Foo",
"manager": "Little John",
"salary": 50
}
]
Output (Avro schema)
{
"name": "MyClass",
"type": "array",
"namespace": "com.acme.avro",
"items": {
"name": "MyClass_record",
"type": "record",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "department",
"type": "string"
},
{
"name": "manager",
"type": "string"
},
{
"name": "salary",
"type": "int"
}
]
}
}
A Json Schema as input would be good as well.
This question was asked a while ago but hast no good answer.
There is a website which does this but I want a library or cli.
Thanks!