func()

in datahub/resultmodel.go [216:251]


func (gtr *GetTopicResult) UnmarshalJSON(data []byte) error {
	msg := &struct {
		ShardCount     int         `json:"ShardCount"`
		LifeCycle      int         `json:"LifeCycle"`
		RecordType     RecordType  `json:"RecordType"`
		RecordSchema   string      `json:"RecordSchema"`
		Comment        string      `json:"Comment"`
		CreateTime     int64       `json:"CreateTime"`
		LastModifyTime int64       `json:"LastModifyTime"`
		TopicStatus    TopicStatus `json:"Status"`
		ExpandMode     ExpandMode  `json:"ExpandMode"`
	}{}
	if err := json.Unmarshal(data, msg); err != nil {
		return err
	}

	gtr.ShardCount = msg.ShardCount
	gtr.LifeCycle = msg.LifeCycle
	gtr.RecordType = msg.RecordType
	gtr.Comment = msg.Comment
	gtr.CreateTime = msg.CreateTime
	gtr.LastModifyTime = msg.LastModifyTime
	gtr.TopicStatus = msg.TopicStatus
	gtr.ExpandMode = msg.ExpandMode
	if msg.RecordType == TUPLE {
		rs := &RecordSchema{}
		if err := json.Unmarshal([]byte(msg.RecordSchema), rs); err != nil {
			return err
		}
		for idx := range rs.Fields {
			rs.Fields[idx].AllowNull = !rs.Fields[idx].AllowNull
		}
		gtr.RecordSchema = rs
	}
	return nil
}