Skip to content

Commit 11baebd

Browse files
committed
Use int64 when decoding into interface{}
1 parent 2edc636 commit 11baebd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

decode.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,15 @@ func (d *decoder) scalar(n *node, out reflect.Value) bool {
437437
// TODO(v3) Drop this.
438438
out.Set(reflect.ValueOf(n.value))
439439
} else {
440-
out.Set(reflect.ValueOf(resolved))
440+
resolvedv := reflect.ValueOf(resolved)
441+
switch resolvedv.Kind() {
442+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
443+
var t int64
444+
out.Set(resolvedv.Convert(reflect.TypeOf(t)))
445+
default:
446+
out.Set(reflect.ValueOf(resolved))
447+
}
448+
441449
}
442450
return true
443451
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:

0 commit comments

Comments
 (0)