mirror of
https://github.com/goccy/go-yaml.git
synced 2025-12-07 13:49:54 +00:00
Fix decoding of integer keys of map type (#829)
* fix decoding integer keys of map type * use createDecodedNewValue for map key
This commit is contained in:
parent
a7b4bfbcf4
commit
9e98b0c753
2 changed files with 10 additions and 5 deletions
|
|
@ -1750,14 +1750,11 @@ func (d *Decoder) decodeMap(ctx context.Context, dst reflect.Value, src ast.Node
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
keyVal, err := d.nodeToValue(ctx, key)
|
||||
keyVal, err := d.createDecodedNewValue(ctx, keyType, reflect.Value{}, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
k = reflect.ValueOf(keyVal)
|
||||
if k.IsValid() && k.Type().ConvertibleTo(keyType) {
|
||||
k = k.Convert(keyType)
|
||||
}
|
||||
k = keyVal
|
||||
}
|
||||
|
||||
if k.IsValid() {
|
||||
|
|
|
|||
|
|
@ -1280,6 +1280,14 @@ c:
|
|||
source: `"\uD83D\uDE00a\uD83D\uDE01"`,
|
||||
value: "😀a😁",
|
||||
},
|
||||
{
|
||||
source: "42: 100",
|
||||
value: map[string]any{"42": 100},
|
||||
},
|
||||
{
|
||||
source: "42: 100",
|
||||
value: map[int]any{42: 100},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.source, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue