From: Matthew W. <mat...@gm...> - 2010-06-08 22:05:45
|
> Have you seen the JSYNC proposal I made last month? http://www.jsync.org Aha, yeah that's exactly what I wanted! and a more concise syntax than mine. I did google for something along these lines ("yaml inside json", etc) but nothing showed up, apologies for the dup :) > I think it covers what you are trying to accomplish here, and even resolves your caveats. It provides everything that you can do in YAML, using standard JSON encoding. Great! There's a few cases which the webpage doesn't include in its examples: * 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"} * An anchor attached to a string/array/some non-map type - my example was {"$anchor": "foo", "$value": "some string"} * Use of one of the special reserved keys "!" or "&" as a normal key of a mapping (would need to be escaped somehow) * A map with non-string keys * A string value which starts with "*" which you don't want treated as a reference On that last point, perhaps it would be easier to do references as {"*": "001"} rather than "*001". That means that you then only need to reserve one other map key, "*", rather than have to reserve (and escape normal uses of) all strings starting with *, noting that this requires every string value to be checked when mapping a parsed JSON tree to a YAML graph. > Want to help me with it? Sure - see the above :) I guess the ultimate awkward corner case would be: A tagged custom type, which is also given an anchor, and which is created from a map with some non-string keys and some (suitably-escaped) reserved keys. Any thoughts on a media type for this? eg application/yaml+json ? 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. -Matt |