문제

I am trying to implement a serializer in python which tries to do something like this.

If there is an object Foo, having a forward reference to Bar, the serializer would dump all the data in Foo, and the reference would be converted into a data dump of Bar. Things would be done recursively like this for any arbitrary depth.

But there is a problem I run into with this approach, that of circular references, what if Foo references Bar and Bar references Foo? An infinite recursion would be created then.

What are the approaches to tackling this problem.

Note: I have no control over the data I would be serializing, so I can't rule out circular references.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top