On Sat, May 1, 2010 at 12:32 AM, William Spitzak <spitzak@rhythm.com> wrote:
How are complex mapping keys supported?

I left this out of the front page example because it is the least important, and might make the example too muddy for the front page. My initial idea was to add an extra mapping to the start of the doc that contained the complex keys (all with anchors) and then reference them below. That would definitely work, but maybe there's a better way.

Something like this
{
  "%": [ ["&1", 3, 5], ["&2", 1, 6] ] },
  "*1": "aaa",
  "*2": "bbb"
}

is:

---
[3, 5]: aaa
[1, 6]: bbb
...

% is a new addition. I also want to add support for YAML's "%TAG" and "%JSYNC" (version).


Only simple way I can see is to disobey JSON syntax and allow maps and lists as the keys.

Plausible but I'm against the idea since I want it to be pure JSON at the parser/emitter level. Implementing JSYNC is just putting a simple constructor and representer over a JSON implementation.
 
A complex way is to invent a few new addresses. Then the following:

       {{foo:bar} : value}

turns into:

       {"&generatedA" : {"foo":"bar"},
        "*generatedA" : "value"
       }

where "generatedA" is an address produced by the from-YAML converter. Big problem with this is that it will not round-trip convert to the identity.


<mailto:ingy@ingy.net>> wrote:

   Greetings from Taiwan,

   I just wrote this up: http://www.jsync.org/

   I'm interested to know what y'all think.

   Cheers, Ingy