In Web Application Development, we use different types of formats for accessing a data over the web. Today, we will compare two different formats JSON (JavaScript Object Notation) and XML (Extensible Markup Language) JSON vs XML. Both have their particular usage for to & fro data passing.
JSON (JavaScript Object Notation) – A model of efficiency
-
A Lightweight text-based open designed for human – readable data interchange manner.
-
It is an alternative to XML that is more efficient because it is not a markup language that requires open and close tags.
-
It is extended from JavaScript.
-
Example :
{ "data" : [ { "id" : "1", "name" : "acadgild" } ] }
XML (Extensible Markup Language) – A Data stuffed
-
An Open Standard for describing data defined by the www (world wide web).
-
It defines mark-up language that allows the developer to certain HTML tags type codes.
-
Example:
<?xml version ="1.0" encoding="UTF-8"?> <root> <data> <id>1</id> <name>acadgild</name> </data> </root>
Difference between XML vs JSON – A Comparision
Features | JSON | XML |
Full Form | JavaScript Object Notation | Extensible Markup Language |
Extend | Extended from JavaScript | Extended from SGML(Standard Generalized Markup Language) |
Speed | Faster in Execution | Slow compared to JSON in Execution |
Arrays Usage | Uses Structured Data Excepting Arrays | Uses Structured Data Including Arrays |
Application | For WebService, JSON is better. | For Configuration, XML is better |
Example |
{ "company": AcadGild, "course": "Android", "price": 16999 } |
<education> <company>AcadGild</company> <course>Android</course> <price>16999</price> </education> |
Comments | Not Supports Comments | Â Supports Comments |
NameSpace | No support for Namespaces | Â Support Namespaces |
APIs | Facebook Graph API, Google Maps API, Twitter API, Pinterest API,Reddit API | Amazon Products Advertising API |
Performance | Good Compared to XML | Not as good when Compared to JSON |
Purpose | Structured Data Interchange | Document Markup |
Database Support | MongoDB, CouchDB, eXistDB, BaseX, Oracle Database, PostgreSQL | MySQL, IBM DB2, Mocrosoft SQL Server, BaseX, MarkLogics |
Light Weight | Lighter than XML | Less Light compared to JSON |
Schema | For Description and DataType and Structure Validation | For DataType, Structure Validation, It also makes possible to create new DataTypes |
Easy to Manipulate | Yes | No |
Security | More Secure | Less Secure |
Choose wisely between JSON & XML. There are some good reasons for using JSON over XML & vice versa. JSON is a better data exchange format. XML is a better document exchange format. Use the right one for the right job.
Keep visiting our site www.acadgild.com for more updates on Android and other technologies.