check is valid fo .object()

This commit is contained in:
Star 2024-10-16 11:47:38 +08:00
parent c78548f50d
commit 4412bfc727

View File

@ -138,8 +138,10 @@ func toObject(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
if data, ok := dataValue.Export().([]byte); ok { if data, ok := dataValue.Export().([]byte); ok {
obj := u.UnJsonBytes(data, nil) obj := u.UnJsonBytes(data, nil)
v := u.FinalValue(reflect.ValueOf(obj)) v := u.FinalValue(reflect.ValueOf(obj))
if v.IsValid() {
return vm.ToValue(v.Interface()) return vm.ToValue(v.Interface())
} }
}
return nil return nil
} }