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 depth wise serialization, you can refer to example here https://github.com/abid-khan/depth-wise-json-serializer