Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with extends class #321

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment
Closed

issue with extends class #321

GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hello,

i have notice that the current example

public class gsonTest {

    public static void main(String[] args) {
        Response r = new Response().add(new B()).add(new A());
        Gson gson = new GsonBuilder().create();
        System.out.println(gson.toJson(r, r.getClass()));
    }

    public static class Response {
        Vector<A> a = new Vector<A>();
        public Response add(A aa) {

            a.add(aa);
            return this;
        }

    }
    public static class A {
        int A = 1;

    }

    public static class B extends A {
        int B = 2;
    }
}


produce
{"a":[{"A":1},{"A":1}]}

instead
{"a":[{"A":1},{"A":1,"B":2}]}


tested on mac/linux/win 1.6 jvm and 1.7.1 gson lib.




Original issue reported on code.google.com by [email protected] on 4 May 2011 at 1:47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant