muba has asked for the wisdom of the Perl Monks concerning the following question:
Preliminary tl;dr: are circular references normally allowed in JSON? And if so, how is it, algorithmically, handled on both ends of a typical browser + AJAX + serverside setup?
Out of curiosity to see if I could do it, and also because I'm not overly happy with the interface of the standard(?) JSON modules out there, I decided to roll my own Perl-to-JSON module (and plan to include a JSON-to-Perl part too, but that's another issue).
Halfway through getting something working surprisingly well, I wondered if it would work if I threw something with a circular reference at it. It did what I expected and hurled itself into an endless loop. Not good, so for the time being I slapped a maximum depth onto it.
That's only a half-assed solution, of course, so I put myself to some research - how does JSON normally "handle" circular references? It didn't take me long to stumble upon the RFC and it doesn't make mention of any such thing.
So, in conclusion, my questions:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (OT) JSON - circular references allowed or not?
by moritz (Cardinal) on Sep 12, 2011 at 15:40 UTC | |
by muba (Priest) on Sep 12, 2011 at 17:47 UTC | |
|
Re: (OT) JSON - circular references allowed or not?
by Anonymous Monk on Sep 12, 2011 at 15:11 UTC |