-
Notifications
You must be signed in to change notification settings - Fork 357
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
One behavior diff with encoding/json #251
Comments
@RainshawGao Could you please provide a minimal repro? |
sure! package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/bytedance/sonic"
jsoniter "github.com/json-iterator/go"
)
func main() {
type test struct {
Name string `json:"name"`
}
var data = ``
test1 := &test{}
err := json.NewDecoder(bytes.NewBufferString(data)).Decode(test1)
if err != nil {
fmt.Printf("std json err: %v\n", err)
} else {
fmt.Printf("std json ok: %v\n", test1)
}
err = jsoniter.ConfigCompatibleWithStandardLibrary.NewDecoder(bytes.NewBufferString(data)).Decode(test1)
if err != nil {
fmt.Printf("josniter err: %v\n", err)
} else {
fmt.Printf("josniter ok\n")
}
err = sonic.ConfigStd.NewDecoder(bytes.NewBufferString(data)).Decode(test1)
if err != nil {
fmt.Printf("sonic err: %v\n", err)
} else {
fmt.Printf("sonic ok\n")
}
} run this gives
|
@RainshawGao Thanks, we will investigate on this. |
@RainshawGao Solved in #254. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I'm trying to add sonic support in gin . And I have found that sonic has a different behavior with encoding/json.
when try to use newDecoder().decode func on an empty string, encoding/json would return an EOF error, while sonic return nothing and an empty struct.
As addressed in https://stackoverflow.com/questions/18419428/what-is-the-minimum-valid-json , an empty string is not a valid json string, so could you please make this behavior the same with encoding/json?
The text was updated successfully, but these errors were encountered: