-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix interpretation of trailing comma when setLenient() is true. #494
Comments
Original comment by
|
Original comment by |
Original comment by |
Original comment by |
I've just been bitten by this. |
Wow I've just seen bug #401 and from what I understand, 🙀 |
🙀 |
Just accidentally stumbled across this while writing tests for our Hadoop REST bindings. It was incredibly surprising and we were lucky to accidentally trigger the bug. Please do correct this, it's not what anybody expects. |
We will not support this behavior change by default. Write better JSON. |
You mean more hideous than the current "happily parse invalid JSON without a warning and result in a very surprising results that nobody should reasonably expect" behavior? |
You can use |
Stumbled across this bug just now and really surprised that this issue is closed. As @BoD said this behaviour, or I really should say this bug, is not a joke, it's a serious thing, causing unexpected hard to catch bugs. And yes, it reproduces even if I really hope this bug will be revisited, analysed and fixed without somewhat insulting "Write better JSON" answers. |
I do think there's a good case to be made for a proper "strict mode" in Gson, which would accept only fully-conformant JSON input. As noted in the documentation for We couldn't make strict mode be the default, because that would risk breaking existing users, but we could certainly recommend its use. I logged #2295 to track having a strict-mode feature. |
@eamonnmcmanus, are you sure about that? For me a non-lenient gson/gson/src/main/java/com/google/gson/stream/JsonReader.java Lines 564 to 569 in 3adf2ad
@mitasov-ra, please follow the advise of the "Lenient JSON handling" section of the |
So is the earlier comment simply wrong? We probably still should have a strict mode for the other reasons detailed in #2295, but if trailing commas are already disallowed when not using lenient mode I think that is perfectly fine. I personally am skeptical whether anybody should ever use lenient mode at all, since it recognizes a more or less random superset of correct JSON. |
Original issue reported on code.google.com by
bolinf...@gmail.com
on 6 Jan 2013 at 11:58The text was updated successfully, but these errors were encountered: