我将JSON文件& JSON Schema解析为AVRO Schema。我有点困惑,我必须使用AVRO文档中定义的数据类型来编写手册AVRO模式吗?
或者,有没有自动化的方法/函数/程序可以完全按照要求工作?
发布于 2016-08-23 14:58:52
你可以试试https://github.com/fge/json-schema-avro,但他们说它还不完整。所以我不确定它会不会起作用
发布于 2017-05-09 19:47:54
avro4s在编译时从case类派生模式:
import com.sksamuel.avro4s.SchemaFor
object Avro {
case class MyAvroClass(s: String, i: Int)
def main(args: Array[String]): Unit = {
val avroSchema = SchemaFor[MyAvroClass]()
println(avroSchema.toString(true))
}
}收益率:
{
"type" : "record",
"name" : "MyAvroClass",
"namespace" : "tests",
"fields" : [ {
"name" : "s",
"type" : "string"
}, {
"name" : "i",
"type" : "int"
} ]
}https://stackoverflow.com/questions/36689916
复制相似问题