<p class="justify"><strong>hello</strong> world</p>
How would you represent this in JSON? Here is my guess. {
node: "paragraph",
attributes: [{
class: "justify"
}],
children: [{
node: "strong",
content: "hello"
},{
node: "text",
content: "world"
}]
}
There is a few things to note between these two examples.In the XML version it is much easier to distinguish the actual content from the meta data. Right away we can see the p tag describing the content "hello world" with metadata as class/justify.
Also, since webpages are all text (we can view this as there is no data type) JSON may become less valuable. We don't really describe types well in XML, but that shouldn't matter on a webpage since it is only text. Where as in a data serialization format, like JSON, that sort of thing is extremely important.
I don't feel strongly about XML, but I don't think I want to use the same format for describing data as I do to describe my documents.
I guess the answer is contained in the expletive: "Boo!"
The biggest reason is that HTML was designed to mark up human-readable documents, rather than to describe machine-readable documents. You can remove all the markup from a web page and easily read its contents; you can't do the same with JSON.
(html (head (title "Hi there"))
(body (h1 "Hi there")
(p "S-expressions are "
(b "a lot nicer")
" than HTML/XML/etc.")))No one was able to answer this question.
{
type: "tag",
tag: "p",
children: [
{type: "text", content: "This is a statement with "},
{type: "tag", tag: "strong", children: [
{type: "text", content: "bold text"}
]}
]
}
That also rather explains why we don't use JSON.