www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Serialization library with support for circular references?

reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
I've been using msgpack for a while, unfortunately I've just
discovered it doesn't support serializing circular references
(http://jira.msgpack.org/browse/MSGPACK-81), e.g.:

import msgpack;

class Foo
{
    int x;
    Bar obj;
}

class Bar
{
    int x;
    Foo obj;
}

void main()
{
    auto foo = new Foo();
    auto bar = new Bar();
    foo.obj = bar;
    bar.obj = foo;
    ubyte[] data = msgpack.pack(foo);
}

Orange doesn't work with circular references either. Is there any
other serialization library that supports this scenario? I'm looking
for something fast, and binary format is ok, I don't need a
user-readable format.
Nov 10 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-11-10 13:42, Andrej Mitrovic wrote:

 Orange doesn't work with circular references either. Is there any
 other serialization library that supports this scenario? I'm looking
 for something fast, and binary format is ok, I don't need a
 user-readable format.
If Orange doesn't work with circular references it's a bug, please file an issue: https://github.com/jacob-carlborg/orange Although Orange is probably not very fast and it currently only has an XML archive. -- /Jacob Carlborg
Nov 10 2012
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 11/10/12, Jacob Carlborg <doob me.com> wrote:
 Although Orange is probably not very fast and it currently only has an
 XML archive.
Heh yeah I'm actually reading XML into classes and then want to serialize this for faster access when re-running the app, so it probably wouldn't be a good idea to serialize back to XML.
Nov 10 2012