json 和 XML 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19627284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between json and XML?
提问by Dharni
What is the difference between json and XML?Which is better in performance aspect while working with android?Why json is described as lightweight?
json 和 XML 有什么区别?用 android 时哪个在性能方面更好?为什么 json 被描述为轻量级?
回答by sam
I suggest you to read the following link below first
我建议您先阅读以下链接
The first comment clearly explains your first two questions.
第一条评论清楚地解释了您的前两个问题。
and for the last question my suggestion would be JSON, The reason is that JSON is light weight and also its very easy to handle and parse when comparing to XML formats. also I believe that JSON started overtaking the technology over XML in many aspects. There are tons and tons of examples and discussions available in web to support the JSON format over XML.
对于最后一个问题,我的建议是JSON,原因是 JSON 重量轻,而且与 XML 格式相比,它很容易处理和解析。我也相信JSON 在许多方面开始超越 XML 的技术。Web 中有大量示例和讨论可用于支持 JSON 格式而不是 XML。
And for Android, since it is a technology which is going to rule the world for next few decades you must decide whether you need to choose the older technology(XML)which is getting down or the newer technology (JSON)which is growing up. The choice is yours.
对于 Android,由于它是一项将在未来几十年内统治世界的技术,因此您必须决定是否需要选择正在下降的旧技术 (XML)或正在成长的更新技术 (JSON)。这是你的选择。
回答by suhailvs
a sample jsonformat is:
示例json格式是:
{
"note": {
"to": "Tove",
"from": "Jani",
"heading": "Reminder",
"body": "Don't forget me this weekend!"
}
}
were its xmlis:
它xml是:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
please refer this SO question
请参考这个问题
回答by TGH
Xml and JSON are two different formats for representing data. A common usage for both is to serve as a serialization format for objects. Which one is better comes down to personal preference. Some frameworks are better designed to work with one over the other.
Xml 和 JSON 是表示数据的两种不同格式。两者的常见用法是用作对象的序列化格式。哪个更好取决于个人喜好。一些框架更好地设计为与另一个一起工作。
As far as performance goes... JSON is less verbose, so it can be more efficient to transfer over the wire.
就性能而言...... JSON 不那么冗长,因此通过网络传输可以更有效。

