-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser does not fully validate the JSON #88
Comments
Another example: package main
import (
"fmt"
"github.com/valyala/fastjson"
)
func main() {
v, err := fastjson.ParseBytes([]byte(`[127.0.0.1]`))
if err != nil {
fmt.Println("failed:", err.Error())
} else {
fmt.Println("passed:", v.Type())
}
err = fastjson.ValidateBytes([]byte(`[127.0.0.1]`))
if err != nil {
fmt.Println("validation failed:", err.Error())
}
// Output:
// passed: array
// validation failed: cannot parse JSON: cannot parse array: missing ',' after array value; unparsed tail: ".0.1]"
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I was checking out
fastjson
and noticed that some invalid JSON strings were accepted without error, e.g. the following program:That is, calling
fastjson.Validate
properly catches the error, butParser.Parse
doesn't. Is that to be expected (the README does mention "Validates the parsed JSON unlike ...")? Having to callValidate
prior to parsing any value to ensure its correctness would obviously make the performance benefits much less interesting, but maybe I'm missing something.Thanks,
Martin
The text was updated successfully, but these errors were encountered: