Avro模式与对象映射?

时间:2020-09-27 12:54:46

标签: go maps avro

type Job struct {
   Name string
   MaskSchema map[string]MaskInfo
}


type MaskInfo struct {
  Masked bool
  SortCol bool
}

如何将Job表示为avro模式?

1 个答案:

答案 0 :(得分:0)

您可以使用goavro


type Job struct {
   Name string
   MaskSchema map[string]MaskInfo
}


type MaskInfo struct {
  Masked bool
  SortCol bool
}

newJob := Job{
    // fill the struct
}

textual, err = codec.TextualFromNative(nil, newJob)
if err != nil {
    fmt.Println(err)
}

fmt.Println(string(textual))

注意:我没有测试它,但是它应该可以工作。

请参阅文档:https://github.com/linkedin/goavro