Numbers allows returning only the attributes whose content is a JSON number. 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)
| 248 | // to receive any error that might have be raised during the attribute |
| 249 | // decoding |
| 250 | func (attributes Attributes) Numbers(errorHolder *error) map[string]float64 { |
| 251 | result := map[string]float64{} |
| 252 | for key := range attributes { |
| 253 | // Here only the last error is returned. |
| 254 | // Let's keep it simple and avoid adding a dependency |
| 255 | // on an external package just for gathering errors. |
| 256 | if value, isRightType := attributes.Get(key, errorHolder).(float64); isRightType { |
| 257 | result[key] = value |
| 258 | } |
| 259 | } |
| 260 | return result |
| 261 | } |
| 262 | |
| 263 | // Booleans allows returning only the attributes whose content |
| 264 | // is a JSON boolean. |