-
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
error happend when converting object to json #399
Comments
Original comment by
|
Original comment by |
Original comment by |
Original comment by |
Original comment by |
I recently got below error: The reason is I used "private final java.text.DecimalFormat" in a class which is deserialized by Gson. And DecimalFormat and its base class NumberFormat, both define "private int maximumIntegerDigits". But my point is, as gson knows duplicate fields, if they are same type, can gson just deserialize the value to subclass instead of throwing an exception? |
That's only half the problem. What if they have different values when serializing? You should not be relying on the implementation details of |
Agree. @JakeWharton. Not a good way to have duplicate fields. But the condition is if we cannot modify those classes and we have to use them, it's better that gson provides a work around. |
I just told you the workaround: a type adapter which doesn't serialize This is less of a workaround and more just the correct thing to do. On Fri, Feb 5, 2016 at 11:39 AM William notifications@github.com wrote:
|
Original issue reported on code.google.com by
jackydu1...@gmail.com
on 11 Jan 2012 at 3:50The text was updated successfully, but these errors were encountered: