HTML would be much easier to write if it were based on JSON. Less bandwidth too. Has this been attempted?
Currently:
<ul>
<li>Hello!</li>
</ul>
By your suggestion: {
"tagName": "ul",
"children": [
{
"tagName": "li",
"children": [
"Hello!"
]
}
]
}
(and, yes, it has been attempted... JSON.stringify(document.body)) {
'ul': {
'li': 'hello!'
}
}
I would think it would depend upon the parser.Regardless, I'd still rather write out HTML instead of JSON for markup.
<p>Example <b>text</b></p>I'm going to go with that JSON is the failure point with my grand vision.
I guess I'm not changing the world today.
One of two things will happen, depending on your browser.
If your browser is following the WebIDL spec, so all the accessors are on the prototype, this will produce "{}".
If your browser is WebKit-based, this will throw an exception, because body.firstChild.parentNode == body and JSON.stringify throws on object graphs with loops.
(:ul (:li Hello))It would be much easier as a Lisp S-EXP.
And yes, it has been attempted.