discomarathon / google-gson

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

Custom Deserializer is not used when calling directly gson.fromJson(jsonString, MyCustomClass.class) #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define a MyCustomClass
2. Build a gson instance, with a MyCustomClassDeserializer bound to it.
3. Try to deserialize directly a string to MyCustomClass (i.e. the
MyCustomClass instance is not a member of an object to deserialize, it IS
the object to deserialize)

What is the expected output? What do you see instead?
The JVM should pass through MyCustomClassDeserializer.deserialize, instead
it searches for a no arg constructor in MyCustomClass

What version of the product are you using? On what operating system?
v1.2.3 on WinXP SP3.

Please provide any additional information below.
N/A

Original issue reported on code.google.com by nicolas....@gmail.com on 9 Dec 2008 at 3:53

GoogleCodeExporter commented 9 years ago
An instance creator (or default constructor) is no longer required when 
registering a
custom deserializer.  As a "temporary" fix, you can have your type adapter 
implement
a "InstanceCreator" for your object.  This instance create returns a dummy 
object
which will just get discarded and garbage collected later.

We are going to try and push a new release within the next couple of weeks.

Original comment by joel.leitch@gmail.com on 13 Dec 2008 at 8:51