sunil1989 / google-gson

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

Arrays referenced in Object field serialization bug #234

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the test

    public class ComplexObj {
        public double[] result;
        public Object obj;
    }

    @Test
    public void json_pretty_printing_bug() {
        GsonBuilder builder = new GsonBuilder();
        Gson gson = builder.create();
        ComplexObj response = new ComplexObj();
        response.result=new double[2];
        response.result[0] = 2.5;
        response.result[1] = 2.5;
        response.obj=response.result;
        assertEquals("{\"result\":[2.5,2.5],\"obj\":[2.5,2.5]}", gson.toJson(response));
    }

What is the expected output? What do you see instead?
Expected: {"result":[2.5,2.5],"obj":[2.5,2.5]}
Actual: {"result":[2.5,2.5],"obj":{}}

What version of the product are you using? On what operating system?
1.5

Please provide any additional information below.
This is a regression, i'm switching from gson-1.3 to gson-1.5 as suggested 
here: http://code.google.com/p/google-gson/issues/detail?id=233

Original issue reported on code.google.com by gianmarco.gherardi on 12 Sep 2010 at 1:12

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 6 Oct 2010 at 6:08