Strings allows returning only the attributes whose content is a JSON string. 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)
| 229 | // to receive any error that might have be raised during the attribute |
| 230 | // decoding |
| 231 | func (attributes Attributes) Strings(errorHolder *error) map[string]string { |
| 232 | result := map[string]string{} |
| 233 | for key := range attributes { |
| 234 | // Here only the last error is returned. |
| 235 | // Let's keep it simple and avoid adding a dependency |
| 236 | // on an external package just for gathering errors. |
| 237 | if value, isRightType := attributes.Get(key, errorHolder).(string); isRightType { |
| 238 | result[key] = value |
| 239 | } |
| 240 | } |
| 241 | return result |
| 242 | } |
| 243 | |
| 244 | // Numbers allows returning only the attributes whose content |
| 245 | // is a JSON number. |