3 ms·
JSON is probably a better format for describing data, but maybe not for document markup. Take the following code snipit: <p class="justify"><strong>hello</st
by ryanto 13y ago
JSON is probably a better format for describing data, but maybe not for document markup. Take the following code snipit:
<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.