go-jsonschema
go-jsonschema copied to clipboard
special case objects with only string values
When unmarshalling, I think we can special-case when the json represented only includes string fields.
Instead of
func (j *Download) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["architecture"]; !ok || v == nil {
this
func (j *Download) UnmarshalJSON(b []byte) error {
var raw map[string]string
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["architecture"]; !ok || v == "" {