bsed / google-gson

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

Handle EnumSet properly #509

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
https://groups.google.com/d/msg/google-gson/1d7EtAcSly0/Lk9WW1LLcSsJ

     EnumSet<Color> foo = EnumSet.of(Color.blue, Color.red);
        String json = gson.toJson(foo);
        EnumSet<Color> bar = (EnumSet<Color>)gson.fromJson(json, new TypeToken<EnumSet<Color>>() {}.getType());
        System.out.printf("foo: " + foo + "\nbar: " + bar + '\n');

Gson returns a LinkedHashSet that causes ClassCastException.

Original issue reported on code.google.com by inder123 on 27 Mar 2013 at 2:22

GoogleCodeExporter commented 9 years ago
Fixed in r1228

Original comment by inder123 on 4 Apr 2013 at 9:16