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{})
| 204 | // An error is returned if the provided interface type is not compatible |
| 205 | // with the attribute content |
| 206 | func (attributes Attributes) GetInto(key string, into interface{}) error { |
| 207 | var err error |
| 208 | if attribute, exists := attributes[key]; exists { |
| 209 | err = json.Unmarshal(attribute.Raw, into) |
| 210 | } else { |
| 211 | err = &KeyNotFoundError{Key: key} |
| 212 | } |
| 213 | return err |
| 214 | } |
| 215 | |
| 216 | // Strings allows returning only the attributes whose content |
| 217 | // is a JSON string. |
no outgoing calls
no test coverage detected