* fix: #2672

* chore: fix more cases

* chore: update deps

* chore: update deps

* chore: refactor

* chore: refactor

* chore: refactor
This commit is contained in:
Kevin Wan
2022-12-11 00:41:50 +08:00
committed by GitHub
parent ef22042f4d
commit fdc57d07d7
14 changed files with 157 additions and 65 deletions

View File

@@ -735,8 +735,16 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue inter
default:
switch v := keythData.(type) {
case bool:
if dereffedElemKind != reflect.Bool {
return emptyValue, errTypeMismatch
}
targetValue.SetMapIndex(key, reflect.ValueOf(v))
case string:
if dereffedElemKind != reflect.String {
return emptyValue, errTypeMismatch
}
targetValue.SetMapIndex(key, reflect.ValueOf(v))
case json.Number:
target := reflect.New(dereffedElemType)
@@ -746,6 +754,10 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue inter
targetValue.SetMapIndex(key, target.Elem())
default:
if dereffedElemKind != keythValue.Kind() {
return emptyValue, errTypeMismatch
}
targetValue.SetMapIndex(key, keythValue)
}
}