jasonzue / google-gson

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

Enum with body does not serialize #226

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Given this test:

enum Toy{
        CAR
}

@Test
    public void serializeEnums()
    {
        assertEquals("\"CAR\"",new Gson().toJson(Toy.CAR));

   }

... the serialization works fine. If I add body to the enum, however:

enum Toy{
        CAR{ /** Empty body **/}
}

.. the result is an empty string.

Tested on version 1.5.

Original issue reported on code.google.com by tfn...@gmail.com on 26 Aug 2010 at 4:09

GoogleCodeExporter commented 9 years ago
Yikes. We're probably using getClass() rather than getDeclaringClass(). Should 
be straightforward fix.

Original comment by limpbizkit on 27 Aug 2010 at 2:38

GoogleCodeExporter commented 9 years ago
Fixed by r583.

Original comment by limpbizkit on 27 Aug 2010 at 7:27