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