Closed GoogleCodeExporter closed 9 years ago
You can use Gson to serialize/deserialize nested classes; however, the nested
classes
need to be "static" nested classes.
Note that the Java language has two types of "nested" classes:
1. Inner Class
2. Static Nested Class
An Inner Class has an implicit reference to the "this" instance of the outer
class.
This is why an inner class can access the private instance members of its outer
class.
A Static Nested Class does not get this implicit reference. You can have it
store a
reference to A, but you will need to explicitly pass in a reference to the
outer class.
Try changing your example as follows:
public class A {
public String i;
public int t;
public B[] q;
//no arg constructor for A
static class B {
public String j;
public String[] k;
//no arg constructor for B
}
}
Hope this helps,
Joel
Original comment by joel.leitch@gmail.com
on 29 Sep 2009 at 5:56
Original issue reported on code.google.com by
radha.te...@gmail.com
on 8 Jul 2009 at 10:04