|
@@ -3,6 +3,7 @@ package goja
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
"math"
|
|
"math"
|
|
@@ -20,6 +21,9 @@ func (r *Runtime) builtinJSON_parse(call FunctionCall) Value {
|
|
d := json.NewDecoder(strings.NewReader(call.Argument(0).toString().String()))
|
|
d := json.NewDecoder(strings.NewReader(call.Argument(0).toString().String()))
|
|
|
|
|
|
value, err := r.builtinJSON_decodeValue(d)
|
|
value, err := r.builtinJSON_decodeValue(d)
|
|
|
|
+ if errors.Is(err, io.EOF) {
|
|
|
|
+ panic(r.newError(r.global.SyntaxError, "Unexpected end of JSON input (%v)", err.Error()))
|
|
|
|
+ }
|
|
if err != nil {
|
|
if err != nil {
|
|
panic(r.newError(r.global.SyntaxError, err.Error()))
|
|
panic(r.newError(r.global.SyntaxError, err.Error()))
|
|
}
|
|
}
|