From: Matthew W. <mat...@gm...> - 2010-06-09 12:03:56
|
> * A tagged custom type which is constructed from (say) a string rather than from a map - my example was {"$tag": "!!timestamp", "$value": "2001-12-15T02:59:43.1Z"} My apologies, I just spotted this in your example on a second look ("!!date March 2, 1962") and from that I could have guessed what you intended for an anchored string too. I guess there's a trade-off to be made here between conciseness and speed/ease of parsing. One of my goals was to get as much mileage as possible out of fast native JSON parsers, so I tended towards letting the JSON parser do as much of the work as possible, rather than encoding things in strings which I would then need to parse myself in javascript. The only overhead which it adds in the common case, is traversing the parsed JSON tree for objects and checking for at most 3 special key names on each object encountered, whereas yours additionally needs to visit each string with a regexp. But then again my proposal is less concise when it comes to serializing. Using "!", "&", "*" keys (as per your proposal) rather than "$tag", "$anchor", "$alias" etc would help a bit with that though. > "!!int 55": "I can't drive", Presume you also have a plan for the case where the key is an object too? :) > Also, I guess an alternative approach (or perhaps one which is undertaken in parallel?) would be to propose an extension to json with new syntax for references and tags, to match the YAML model, but only the minimal extra syntax required to do so, with the goal of keeping it as easy to parse as possible. > > Explain this more. I don't really see what you are proposing... I was wondering about defining (as a parallel effort) some minimal syntax extensions to JSON which add the features (tags, anchors etc) required for the YAML model, but without going as far as full yaml syntax, eg something like: { "foo": *anchor, "bar": !date &anchor "2010-01-01", 123: 456, ... } It would require an extended JSON parser to deal with it of course, but still a fair bit easier to parse than full YAML syntax. Perhaps a bit of a half-baked idea, but it might complement the goals of JSYNC somewhat, defining something which is easier to parse but supports the full YAML model with tags/aliases, and also offering a version of it which is embedded within plain JSON as an alternative for cases where you want to be able to use a plain JSON parser. -Matt |