I have a class that looks like this:
public class Person {
public class Address {
private String line1;
private String line2;
private
Correct, this used to be something you can not do with current Jackson versions (1.8 and earlier). But is it absolutely necessary for inner class to be non-static? If not, just add 'static' in declaration of Address and it'll work fine; problem is with the "hidden" this-pointer that non-static inner classes take via constructor.
Jackson 1.9 will actually supports deserialization of simple uses of non-static inner classes, see this Jira entry.
Because inner classes do not have a default zero argument constructor (they have a hidden reference to the outer/parent class) Jackson cannot instantiate them.
The solution is to use static
inner classes:
public class Outer {
static class Inner {
private String foo;
public String getFoo() { return foo; }
}
}
Original Answer:
There are some issues in implementation and it seems like you can't serialize such classes, see cowtowncoder for details.