discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
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