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
GSON deserializes int as Double... #5
Comments
Try to add:
in src/main/java/io/github/karol_brejna_i/tigergraph/restppclient/invoker/JSON.java |
==> java.lang.IllegalArgumentException: field com.google.api.services.books.v1.model.Volumes.totalItems has type java.lang.Integer, got java.lang.Long
==> java.lang.IllegalArgumentException: field com.google.api.services.books.v1.model.Volumes.totalItems has type java.lang.Integer, got java.lang.Double What is a solution to deserialize json com.google.api.services.books.v1.model.Volumes.class ? |
@bdoobli For me, the following resolved previous issue:
I see GsonFireBuilder is used here (as opposed to your GsonBuilder. Take a look at the source code (https://github.com/karol-brejna-i/tigergraph-restpp-client/blob/develop/src/main/java/io/github/karol_brejna_i/tigergraph/restppclient/invoker/JSON.java), maybe there are more differences. |
I tested your GsonFireBuilder without success. With another deserializer com.google.api.client.json.JsonSolution there is a solution
Still wondering how to use Gson with google api services like com.google.api.services.books.v1.model.Volumes |
It turns out it is a default behaviour of GSON.
For example, int the following response:
personId
,xCount
are long numbers. They were deserialized to Double.In one of the newer versions of GSON there is a switch that disables the "feature".
See: google/gson#1290
Use the switch to make integers great again...
The text was updated successfully, but these errors were encountered: