Skip to content
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

java.lang.IllegalArgumentException when giving a double in place of a String #25

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

Try to parse {"version": 1.0} into class A { String version; }

What is the expected output? What do you see instead?

I expect a JsonParsingException, but instead get:

java.lang.IllegalArgumentException: Can not adapt type class java.lang.Double 
to class 
java.lang.String
    at com.google.gson.PrimitiveTypeAdapter.adaptType(PrimitiveTypeAdapter.java:64)
    at com.google.gson.TypeAdapterNotRequired.adaptType(TypeAdapterNotRequired.java:51)
    at 
com.google.gson.JsonObjectDeserializationVisitor.visitPrimitiveField(JsonObjectD
eserializationVis
itor.java:131)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:177)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:152)
    at 
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextD
efault.java:75)
    at 
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefaul
t.java:47)
    at com.google.gson.Gson.fromJson(Gson.java:326)
    at com.google.gson.Gson.fromJson(Gson.java:299)

What version of the product are you using? On what operating system?
v1_1 on Linux

Please provide any additional information below.


Original issue reported on code.google.com by ch...@gmail.com on 29 Jul 2008 at 10:21

@GoogleCodeExporter
Copy link
Author

Original comment by joel.leitch@gmail.com on 30 Jul 2008 at 11:55

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Fixed in r125.  Expected to roll out with Release 1.2.

Original comment by joel.leitch@gmail.com on 31 Jul 2008 at 12:49

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant