Why is JSON more lightweight than XML?

2020-06-01 01:27发布

I was finding the difference between JSON and XML. As, both are for data interchange between systems, but there is a big difference between JSON and XML that JSON is more lightweight than XML. But I am unable to find the actual reason that why the JSON is light-weight. What makes JSON light-weight??

One answer I found is that in JSON there is not a lot of extra xml markup. What does it actual mean. Are there some more reasons that describes why JSON is lightweight?

标签: xml json
7条回答
We Are One
2楼-- · 2020-06-01 02:10

It's just smaller by a linear factor. That's not really smaller. Once compressed, both formats take about the same space.

Remember that programs that already have to use XML aren't going to get simpler by also allowing JSON, they'll get more complex. Extra standards only complicate things unless you get rid of the old standards, and XML isn't going to disappear soon.

XML was designed around the concept of a document. JSON was more about simple data structures. JSON cares less about standards, i.e. it has no schemas, so portability may be more difficult than for someone skilled in using XML. Usually when I have to use some ReSTful service, I'm told to 'read the code' or 'look at the JSON data itself' in order to understand it. I.e. implicit (and quite often, changing) data formats.

Both formats suffer from the problem that they can, in their natural form, only represent trees, not graphs of data. I don't like either format. They both seem half-finished. Object serialisation solves more problems.

查看更多
登录 后发表回答