-
Notifications
You must be signed in to change notification settings - Fork 431
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
encoding/json accepts case-insensitive keys, while easyjson doesn't #10
Comments
Yeah, got this too! Thanks! |
I'm thinking about adding case-insensitive keys as an option which is turned off by default since case insensitivity will hurt the performance somewhat. snake_case option in not exactly the same as lowercase: it also adds underscores between consecutive words. |
Any idea on when this will hit a released version? I need this bad. It would kill every single user of my API if I had to change the payloads they send me. On the other hand, having easyjson decode the payloads speeds up my app considerably. |
Btw, in order NOT to get the performance penalty, one easy way of achieving the same would be hinting EasyJSON with the json name. Something like:
Very much like encoding/json already does. Thanks for the great work. |
I'm sorry, I just found out that the json comment already works. Sorry for that. |
Yes, json tags work. Sorry I haven't explicitly pointed that out as a workaround. I did experiment with standard name matching, but I was unable to come up with a version without significant performance penalty. The issue here is not case insensitivity, but mostly having "better" and "worse" matches in 'encoding/json'. Adding this logic makes the serializer slow, defeating the whole purpose of using a non-standard json serializer. For me it looks like this: if you don't care about performance at all, you should probably use "encoding/json". If you do, using tags is not a huge overhead and there will be no magic name matching involved. Less magic = predictable performance. I'm closing this as wontfix. If tags are not enough — feel free to reopen with a use case. |
t2.go:
t2_test.go:
Without easyjson-generated code the test is passed; with it it fails:
This behaviour should be either documented or fixed.
The text was updated successfully, but these errors were encountered: