-
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
Long upper limit value #1727
Comments
Most likely a bug. The built-in
As a workaround you might want to add the following custom long values type adapter to your final class LongTypeAdapter extends TypeAdapter<Long> {
private LongTypeAdapter() {}
private static final TypeAdapter<Long> instance = new LongTypeAdapter().nullSafe();
static TypeAdapter<Long> get() { return instance; }
@Override public void write(final JsonWriter out, @Nonnull final Long value) throws IOException { out.value(value); }
@Override @Nonnull public Long read(final JsonReader in) throws IOException { return Long.parseLong(in.nextString()); }
} Not sure if this bug can be fixed not breaking the previous versions of Gson. |
Fixing this would probably require writing an own
Edit: Or the validation could only be added for integral values which match the pattern described by |
Use Gson
Use JsonPrimitive
Use Long.valueOf
Why is there no error in Gson?
Is this a bug? Or is it a specification?
I want an error to occur.
The text was updated successfully, but these errors were encountered: