XML vs JSON

ParametersXMLJSON
AbbreviationExtensible Markup LanguageJavaScript Object Notation
SyntaxIt is structured as a tree (tags and nodes)It is structured as key and value pairs
Namespace supportIt supports namespace.It does not support namespace.
Array SupportIt does not support an array.It supports an array.
SpeedBulky and slow in parsing, leading to slower data transmissionVery fast as the size of the file is considerably small, faster parsing by the JavaScript engine and hence faster transfer of data
SecurityXML structures are prone to some attacks as external entity expansion and DTD validation are enabled by default. When these are disabled, XML parsers are safer.JSON parsing is safe almost all the time except if JSONP is used, which can lead to a Cross-Site Request Forgery (CSRF) attack.
Data Types SupportSupports many complex data types including charts, images, and other non-primitive data types.JSON supports only strings, numbers, arrays Boolean, and objects. Even objects can only contain primitive types.
UTF SupportXML supports UTF-8 and UTF-16 encodings.JSON supports UTF as well as ASCII encodings.