Faster is not an attribute of JSON or XML or a result that a comparison between those would yield. If any, then it is an attribute of the parsers or the bandwidth with which you transmit the data.
Here is (the beginning of) a list of advantages and disadvantages of JSON and XML:
JSON
Pro:
- Simple syntax, which results in less "markup" overhead compared to XML.
- Easy to use with JavaScript as the markup is a subset of JS object literal notation and has the same basic data types as JavaScript.
- JSON Schema for description and datatype and structure validation
- JsonPath for extracting information in deeply nested structures
Con:
XML
Pro:
- Generalized markup; it is possible to create "dialects" for any kind of purpose
- XML Schema for datatype, structure validation. Makes it also possible to create new datatypes
- XSLT for transformation into different output formats
- XPath/XQuery for extracting information in deeply nested structures
- built in support for namespaces
Con:
- Relatively wordy compared to JSON (results in more data for the same amount of information).
So in the end you have to decide what you need. Obviously both formats have their legitimate use cases. If you are mostly going to use JavaScript then you should go with JSON.
Please feel free to add pros and cons. I'm not an XML expert ;)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…