I am developing log library that serializes java objects into JSON, however, I faced with the problem that some objects can refer to themselves and eventually might recursively create infinite JSON. I need a functionality where I can specify the depth of serialization or somehow prevent recursion. Can someone suggest any solution?
P.S. Jackson and GSON don't seem to have this functionality.