GetInto allows decoding the attribute with the given key into a given interface. The provided interface should be a pointer to a struct, to an array, or to any simple type. An error is returned if the provided interface type is not compatible with the attribute content
(key string, into interface{})
| 213 | // An error is returned if the provided interface type is not compatible |
| 214 | // with the attribute content |
| 215 | func (attributes Attributes) GetInto(key string, into interface{}) error { |
| 216 | var err error |
| 217 | if attribute, exists := attributes[key]; exists { |
| 218 | err = json.Unmarshal(attribute.Raw, into) |
| 219 | } else { |
| 220 | err = &KeyNotFoundError{Key: key} |
| 221 | } |
| 222 | return err |
| 223 | } |
| 224 | |
| 225 | // Strings allows returning only the attributes whose content |
| 226 | // is a JSON string. |
no outgoing calls