zcourts/higgs

Add support for circular references

zcourts opened this issue · 2 comments

As with any object serializer in Java Higgs will need to handle circular references. Jackson and GSON both have pretty good implementations/support for this so those are possible ways of doing it.
For e.g. see http://code.google.com/p/google-gson/issues/detail?id=137

In particular see the referenced file:
http://code.google.com/p/google-gson/source/browse/trunk/extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java

Any use of something like Jackson's JsonNode will cause a stackoverflow because of this.

For now, it'll be made to support them using a recursion depth instead of an object graph. Purely because I don't have the time and it is simpler/quicker to implement.

issue will be left open until the code is refactored to support object graphs and a graph implementation is made.

See http://docs.oracle.com/javase/7/docs/platform/serialization/spec/serial-arch.html
Or "how does it work" at http://jserial.sourceforge.net/faq.html

attempt at adding recursion depth https://gist.github.com/4290900

For future reference.

Circular ref. algorithm inspired by http://beza1e1.tuxen.de/articles/deepcopy.html