Ejemplo n.º 1
0
func (m *Model) translateObjectValue(v map[string]Value, p *reflect.StructValue) interface{} {
	for lbl, _ := range m.Attributes() {
		vl := v[strings.ToLower(lbl)]
		switch vl.Kind() {
		//TODO MakeZero ??
		case IntKind:
			tmp := reflect.NewValue(1).(*reflect.IntValue)
			tmp.Set(int(vl.Int()))
			p.FieldByName(lbl).SetValue(tmp)
		case StringKind:
			tmp := reflect.NewValue("").(*reflect.StringValue)
			tmp.Set(string(vl.String()))
			p.FieldByName(lbl).SetValue(tmp)
		}
	}
	m.object_cache[int(v[strings.ToLower(m.identifier)].Int())] = v
	return p.Interface()

}