in reply to (OT) JSON - circular references allowed or not?

JSON serializes a tree, so no circular data structures out of the box.

Of course you can still establish circular data structures by convention and post-processing (for example give each objecht an __id__, and allow references like __ref__:$object_id).

One attempt to specify such a system is jsync, which uses the ideas from YAML, but stays with a JSON syntax.

(Note that JSON is not a serialization format, but rather a data exchange language, and thus is limited to a feature set available in nearly all programming languages).

Replies are listed 'Best First'.
Re^2: (OT) JSON - circular references allowed or not?
by muba (Priest) on Sep 12, 2011 at 17:47 UTC

    I had never thought of the distinction between serialization and a data exchange format, thanks for pointing that out. That's a most satisfying answer. If circular references aren't part of standard JSON I'm not going to bother with implementing support for it.

    On a sidenote I'm proud to report that the JSON-to-Perl part is also almost working. It has a few quirks I'm not too happy about but they should be resolved easily.