Consider extending JSON grammar to support objects with circular reference

Marius Gundersen gundersen at gmail.com
Mon Mar 5 04:29:04 PST 2012


>
> JSON.stringfyEx will never produce text like this but JSON.parseEx accept
> this form.
>
> I mean
> {
>     a:11,
>     b:path(/a)
> }
> will act all the same with
> {
>     a:11,
>     b:11
> }
>

So it would produce copies of literals, but references of objects/arrays?

For example:
var obj = {};
obj.b = {};
obj.a = obj.b;

Would produce:

{
  "b": {},
  "a": path(/b)
}

and could be parsed so adding a member to either obj.b or ob.a would update
the other one. This would therefore be more powerfull than simply copying
the same values to the different names when parsing.

Marius Gundersen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120305/b7c082ec/attachment-0001.html>


More information about the es-discuss mailing list