sangmingming / google-gson

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

Cannot deserialize TreeSet #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

TreeSet<String> strings = new TreeSet<String>();
strings.add("Happy");

Gson gson = new Gson();
String json = gson.toJson(strings);

strings = gson.fromJson(json, new TypeToken<TreeSet<String>>() {}.getType());

What is the expected output? What do you see instead?
I would expect it to run without exceptions.  
I am getting the following:
Exception in thread "main" java.lang.ClassCastException:
java.util.LinkedList cannot be cast to java.util.TreeSet

What version of the product are you using? On what operating system?
gson-1.3.jar and gson-1.4.jar  
Running on OSX 10.6

Please provide any additional information below.

Original issue reported on code.google.com by gciar...@gmail.com on 23 Oct 2009 at 1:32

GoogleCodeExporter commented 9 years ago
Thanks for the bug report.
Fixed in r520

Original comment by inder123 on 8 Jan 2010 at 7:15