Skip to content
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

[QUESTION] - Different error message from standard json #336

Closed
sujit-baniya opened this issue Feb 18, 2022 · 3 comments
Closed

[QUESTION] - Different error message from standard json #336

sujit-baniya opened this issue Feb 18, 2022 · 3 comments
Labels
question Further information is requested

Comments

@sujit-baniya
Copy link

Almost all error messages are different from standard json. Shouldn't it require to have same error messages to be 100% compatible?

@sujit-baniya
Copy link
Author

package main

import (
	stdJson "encoding/json"
	"github.com/goccy/go-json"
)

type User struct {
	ID map[string]int `json:"id"`
}

func main() {
	goccyJson()
	// testStdJson()
}

func testStdJson() {
	data := []byte(`{"id": 1}`)
	var user User
	err := stdJson.Unmarshal(data, &user)
	if err != nil {
		panic(err)
	}
}

func goccyJson() {
	data := []byte(`{"id": 1}`)
	var user User
	err := json.Unmarshal(data, &user)
	if err != nil {
		panic(err)
	}
}

image

@sujit-baniya
Copy link
Author

Also the error messages are not helpful as it's not giving the context of the error

@sujit-baniya sujit-baniya changed the title [QUESTION] - Why error messages are different from standard json if this library is compatible [QUESTION] - Different error message from standard json Feb 18, 2022
@goccy goccy added the question Further information is requested label Mar 4, 2022
@goccy
Copy link
Owner

goccy commented Mar 25, 2022

We're aiming for behavior that's compatible with encoding/json, but it doesn't include outputs the exact same error message. So, this is spec .
However, we plan to make corrections to change the error message to a more understandable one in the future.

@goccy goccy closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants