Closed GoogleCodeExporter closed 2 months ago
I have tracked down a bug in our project that is also producing this error
under certain conditions.
Line of code in question here.
Map dataMap = gson.fromJson(jsonReader, Map.class);
Is there a possible work around? As stated this doesn't throw an error 100% of
the time only with certain content. The content is correctly parsed in Jaxson
and on iOS as this error didn't occur until the move to Gson for json parsing.
Original comment by ka...@agilemd.com
on 29 Jan 2015 at 1:06
I know this issue is from a long time ago but I stumbled onto it while having the same error and figured out a solution . It is the map in the DTO that is causing this error as its key is a object . What happens is gson calls toString() for this object to serialize and then gets stuck when recreating the object. if you set the gson up as Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create(); It will fix this issue.
I am going to close this issue. As mentioned above, unfortunately Gson's Map
adapter by default uses toString
for serialization, which can then fail for deserialization.
The workaround is to use GsonBuilder#enableComplexMapKeySerialization()
, see also the related Troubleshooting Guide entry.
Original issue reported on code.google.com by
vaibhav....@gmail.com
on 24 Oct 2014 at 4:58