It is not. Of course some kinds of data are indeed expressed simpler with JSON.
Another real world example is RSS. More data-y that HTML but still may contain mixed content. Would it be better if it had been JSON from the beginning? The answer is not clear cut.
So maybe JSON is not always the right answer. Maybe it depends on what kind of data you want to express. But then it suddely is not a debate with a "XML-defenders" which "dont get it". Then it is a discussion about which tool is approprite in a given situation rather than a war between tribes. And how do you boost you ego and sense of superiority with a boring debate about tools?
"Show me e.g. how a paragraph with a few embedded links is improved by translating to JSON."
Even though HTML and XML are related, something like a web page is so ingrained that would be difficult to change
And JSON was never a markup language
The criticism of XML goes much more towards using it as a 'Key/Value' serialization format.
But you could imagine something like that (commas and colons would have to be replaced in a 'JSON' markup language)
{p: Read it on {href:news.ycombinator.com, a:Hacker News}}
Size gains, parsing speed gains.
RSS is not as clear cut, really, it's not a complicated structure, so it could be YAML for example
"So maybe JSON is not always the right answer. Maybe it depends on what kind of data you want to express"
XML has attributes, which I'm not against (unlike the article) and it has a more natural nesting of information. But for the majority of data, yes, JSON is better
This is about coder productivity (which is increased with JSON it's not even funny), either in Python/Java (even with the whole swiss army knife of XML libs they have)/C# or others.
Speed is also a issue. Encoding and decoding XML is slower, even with C speedups (example: Python lxml). And this is relevant for transformation of data or even sending it to the user.
* SGML is a good idea when the markup overhead is less than 2%. Even attributes is a good idea when the textual element contents is the "real meat" of the document and attributes only aid processing*
In your example where you want to add a small amount of markup to a large amount of text, SGML wins. JSON is a worse choice for such cases.
It seems to me that we have collectively solved these problems, which is why we have both JSON and XML. Naggum was right when he said that XML was being applied incorrectly, and Douglas Crockford solved the problem by introducing JSON.
If one is tired of talking, one's best option is to shut up.
If one is tired of talking, one's best option is to shut up.
Even better, if one's arguments are not being found persuasive, perhaps one should come up with better arguments, or reconsider their position...
If one is too tired to read, one should be too tired to comment on the reading material.
Except that in JSON, strings need to be surrounded by double quotes. Why impose on human readers a syntactic requirement that only compilers/interpreters need?
From this respect, JSON is in the same mixed bag as XML is.
If you want to go down that slope, be consistent and push YAML instead of JSON.
This is a funny limitation, since JSON came from Javascript and {a:1} is perfectly legal in Javascript
"Why impose on human readers a syntactic requirement that only compilers/interpreters need?"
Well, for human readers this can be bad, but <> can be bothersome as well.
YAML could be a better choice (or something similar to JSON but with better syntax)
That's only legal when the key is not a reserved word. I never use that form, as it's error-prone.
XML
<p>Some <b>bold<b> text</p>
JSON { "p": ["Some ", { "b": "bold" }, " text"] }Markdown, rst or something are better. As long as it has a simple deterministic terse grammar that is... If you want you can stuff that inside XML or rst and attach metadata.
Mathematics, English and most notations are too full of nuances to represent things unambiguously.
Really
JSON is better (and XML is crap) it's ridiculous, it's obvious, it's clear cut, and when people "don't get it" you start resorting to irony
Like this:
> Enclose the /element/ in matching delimiters, not the tag
Let's compare them
<blah>foo</blah>
To json
blah: foo
1 - size (json wins)
2 - matching. Here's an exercise, try splitting json with sed, and then try with XML. Sed is a good exercise, because it's limited to simple grammars, so it kind of gives an idea how much trouble it is to parse each one
3 - redundancy: what would mean if the line was <blah>foo</lala> This is a mistake, right? But I can assume the tag name is blah and the data is foo. This is a glaring redundancy in grammar, bound to cause trouble.
Not to mention working with json data (like python) is natural compared to work with XML data.