I use Jackson library for serialization of my pojo objects into JSON representation. For example I have class A and class B:
JSON
class A { privat
For some cases you can limit serialization depth using a thread local integer holding max depth. See this answer.