As I already postulated few weeks ago,
I would like to see an native JSON browser. Including ‘json:’ protocol of course!. That is a browser which receives from a server side, nothing else but a JSON. Using json: protocol. In the same time I am proposing a new JSON based streaming format which I am calling JSONDOM, which is abbreviation of: JSON W3C DOM Markup Language.
Therefore this native JSONDOM browser receives only pages which are structured exactly like the W3C DOM hierarchy is structured today. This is possible because JSON is an object notation. With sub-objects. And this is really and truly lovely. This leads to the following example of JSONDOM page:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
var $page = { JSONML: { ID: "thepage", /*optional*/ DOCTYPE: "json://to-the-def", HEAD: { TITLE: "My JSON Page", CHILDREN: [ { TAG: "style", TYPE: "text/css", RULES: ["body {font: 12px/1.5 Verdana;}", "div {margin:2px;}"] } ] }, BODY: { ID: "thebody", CHILDREN: [ { TAG: "DIV", ID: "thediv", TEXT: "Hello World!" }, { TAG: "SCRIPT", TYPE: "text/javascript", CODE: function() { return $("#thediv").text(); } } ] } } }; } |
Where (obviously )”HEAD”, “DIV”, “BODY”, etc are reserved symbols and are matching HTML tags.
This is simply W3C DOM described in the JSON. The formula here is :
DOM + JSON = JSONDOM
Here we have the opportunity to rectify HTML omissions and impose few rules, like “ID is mandatory”. Therefore there is a set of properties which are mandatory , like “ID”. (Can you think of any other that would be mandatory?)
Thinking of which, and for a “backward” compatibility, I will allow for the “HTML” symbol, whose value is an POHTML aka Plain Old HTML. So this would be legal JSONML :
1 |
{ TAG="DIV" ID="mydiv" , HTML : "<h1>Plain Old HTML</h1>" } |
Where I am still undecided if I will allow for HTML elements to be reachable from JSONDOM scripts. Probably not. If users of this need or want HTML they can always turn back to their favorite plain old HTML browsers.
Oh, what the heck, I shall allow for the “XML” tag too. Therefore this is legal JSONDOM :
1 |
{ TAG="XML", ID="myxml", XML : "XML" } |
This is good for backward compatibility with XML Web Services and simillar dead-ends … There are tons of XML out there. One can use this XML payload same as before, with the help of JavaScript etc…
And, also obviously in this JSONDOM world it is a no brainer to introduce your own tags.
1 |
{ TAG="myTAG" ID="dbj" TEXT="Look Ma, I have my own tag!" } |
One can use or abuse this, which no one can control. I hope standard JSONDOM browsers will conform from the day zero to this simple and single rule : Only W3C DOM is legal.
Hm, I am wondering now, has anyone else thought of this before?