Booleans allows returning only the attributes whose content is a JSON boolean. An optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding
(errorHolder *error)
| 267 | // to receive any error that might have be raised during the attribute |
| 268 | // decoding |
| 269 | func (attributes Attributes) Booleans(errorHolder *error) map[string]bool { |
| 270 | result := map[string]bool{} |
| 271 | for key := range attributes { |
| 272 | // Here only the last error is returned. |
| 273 | // Let's keep it simple and avoid adding a dependency |
| 274 | // on an external package just for gathering errors |
| 275 | if value, isRightType := attributes.Get(key, errorHolder).(bool); isRightType { |
| 276 | result[key] = value |
| 277 | } |
| 278 | } |
| 279 | return result |
| 280 | } |
| 281 | |
| 282 | // Into allows decoding the whole attributes map |
| 283 | // into a given interface. The provided interface should be either a pointer |