Beispiel #1
0
func (s *Hyperlink) Decode(enc interface{}) error {
	err := s.decodeSpan(enc)
	if err != nil {
		return err
	}

	dec, ok := enc.(map[string]interface{})
	if !ok {
		return fmt.Errorf("%+v is not a map", enc)
	}
	v, found := dec["data"]
	if !found {
		return fmt.Errorf("No data found for link %+v", enc)
	}
	dec, ok = v.(map[string]interface{})
	if !ok {
		return fmt.Errorf("%+v is not a map", v)
	}
	t, found := dec["type"]
	if !found {
		return fmt.Errorf("No type found for link %+v", v)
	}
	l, foundlink := dec["value"]
	if !foundlink {
		err = fmt.Errorf("No link value found in %+v", enc)
	}
	s.Link, err = link.Decode(t.(string), l)
	return err
}
Beispiel #2
0
func (l *Link) Decode(t string, enc interface{}) error {
	var err error
	l.Link, err = link.Decode(t, enc)
	return err
}