【发布时间】:2019-08-05 05:27:40
【问题描述】:
我有一个用 Go 编写的 Beam 管道,我想转换这个输入:
{"name": "Bob", "age": 32}
到一个有效的“对象”。
go sdk在编码包中有这个功能:
// UnmarshalJSON sets the state of this instance from the passed in JSON.
func (w *EncodedType) UnmarshalJSON(buf []byte) error {
var s string
if err := json.Unmarshal(buf, &s); err != nil {
return err
}
t, err := graphx.DecodeType(s)
if err != nil {
return err
}
w.T = t
return nil
}
但我不明白如何将它用作我管道的一个步骤。
【问题讨论】:
-
我觉得this 的例子应该对你有所帮助。你能告诉我们管道返回 JSON 记录的位置吗?从那里我们应该能够找到解决方案。
标签: go apache-beam