AsInterface allows returning the whole attributes map... as an interface. When the attributes are not empty, the returned interface will be a map of interfaces. An optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding
(errorHolder *error)
| 308 | // to receive any error that might have occured during the attributes |
| 309 | // decoding |
| 310 | func (attributes Attributes) AsInterface(errorHolder *error) interface{} { |
| 311 | rawJSON, err := json.Marshal(attributes) |
| 312 | if err != nil && errorHolder != nil { |
| 313 | *errorHolder = err |
| 314 | return nil |
| 315 | } |
| 316 | |
| 317 | container := &[]interface{}{} |
| 318 | err = json.Unmarshal([]byte("[ "+string(rawJSON)+" ]"), container) |
| 319 | if err != nil && errorHolder != nil { |
| 320 | *errorHolder = err |
| 321 | return nil |
| 322 | } |
| 323 | |
| 324 | return (*container)[0] |
| 325 | } |
| 326 | |
| 327 | // PutString allows adding a string attribute to the |
| 328 | // current map of attributes |
no outgoing calls